Skip to content

Commit cb38035

Browse files
committed
TASK: Set output to the document identifier for correct deduplication
For suggestions, two hits are deduplicated when they prouce the same output. By default it make sense to deduplicate hits by the linked document, so the document identifier is used. This also reduces the index document size a lot. Also improved documentation and changed the method name as it is not a config that is built.
1 parent daeb93a commit cb38035

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

Classes/EelHelper/SuggestionIndexHelper.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ class SuggestionIndexHelper implements ProtectedContextAwareInterface
2323
{
2424

2525
/**
26-
* @param string $input
27-
* @param array $payload
28-
* @param int $weight
26+
* @param string $input The input to store, this can be a an array of strings or just a string. This field is mandatory.
27+
* @param string $output The result is de-duplicated if several documents have the same output, i.e. only one is returned as part of the suggest result.
28+
* @param array $payload An arbitrary JSON object, which is simply returned in the suggest option.
29+
* @param int $weight A positive integer or a string containing a positive integer, which defines a weight and allows you to rank your suggestions.
2930
* @return array
3031
*/
31-
public function buildConfig($input, array $payload = [], $weight = 1)
32+
public function build($input, $output = '', array $payload = [], $weight = 1)
3233
{
3334
return [
3435
'input' => $this->prepareInput($input),
35-
'output' => $this->prepareOutput($input),
36+
'output' => $this->prepareOutput($output),
3637
'payload' => json_encode($payload),
3738
'weight' => $weight
3839
];

Configuration/NodeTypes.Mixins.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
dimensionCombinationHash:
1717
type: category
1818
path: '__dimensionCombinationHash'
19-
indexing: "${Flowpack.SearchPlugin.Suggestion.buildConfig(q(node).property('title'), {nodeIdentifier: node.identifier}, 20)}"
19+
indexing: "${Flowpack.SearchPlugin.Suggestion.buildConfig(q(node).property('title'), q(node).is('[instanceof Neos.Neos:Document]') ? node.identifier : q(node).parents('[instanceof Neos.Neos:Document]').get(0).identifier, {nodeIdentifier: node.identifier}, 20)}"
2020

2121
'Flowpack.SearchPlugin:AutocompletableMixin':
2222
abstract: true

0 commit comments

Comments
 (0)