Skip to content

Commit 49ccd27

Browse files
committed
TASK: Make Groovy fulltext indexing handle hidden/removed nodes
This removes the fulltext parts for hidden and removed nodes from the fulltext of their root document.
1 parent a461533 commit 49ccd27

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Indexer

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Indexer/NodeIndexer.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,14 @@ protected function updateFulltext(NodeInterface $node, array $fulltextIndexOfNod
332332
if (!ctx._source.containsKey("__fulltextParts")) {
333333
ctx._source.__fulltextParts = new LinkedHashMap();
334334
}
335-
ctx._source.__fulltextParts[identifier] = fulltext;
335+
336+
if (nodeIsRemoved || nodeIsHidden || fulltext.size() == 0) {
337+
if (ctx._source.__fulltextParts.containsKey(identifier)) {
338+
ctx._source.__fulltextParts.remove(identifier);
339+
}
340+
} else {
341+
ctx._source.__fulltextParts[identifier] = fulltext;
342+
}
336343
ctx._source.__fulltext = new LinkedHashMap();
337344
338345
Iterator<LinkedHashMap.Entry<String, LinkedHashMap>> fulltextByNode = ctx._source.__fulltextParts.entrySet().iterator();
@@ -354,6 +361,8 @@ protected function updateFulltext(NodeInterface $node, array $fulltextIndexOfNod
354361
',
355362
'params' => [
356363
'identifier' => $node->getIdentifier(),
364+
'nodeIsRemoved' => $node->isRemoved(),
365+
'nodeIsHidden' => $node->isHidden(),
357366
'fulltext' => $fulltextIndexOfNode
358367
],
359368
'upsert' => [

0 commit comments

Comments
 (0)