Skip to content

Commit b0bf906

Browse files
dfeyerkdambekalns
authored andcommitted
BUGFIX: Include the context document in the query result
The ElasticSearchQueryBuilder::query searches only below the given context document. One example when this is wrong is when you search from the site node, which you use as the homepage - in this case the actual "homepage" would not be searched.
1 parent 6e0e7b0 commit b0bf906

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Classes/Eel/ElasticSearchQueryBuilder.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,17 @@ public function query(NodeInterface $contextNode)
651651
// on indexing, the __parentPath is tokenized to contain ALL parent path parts,
652652
// e.g. /foo, /foo/bar/, /foo/bar/baz; to speed up matching.. That's why we use a simple "term" filter here.
653653
// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-filter.html
654-
$this->queryFilter('term', ['__parentPath' => $contextNode->getPath()]);
654+
// another term filter against the path allows the context node itself to be found
655+
$this->queryFilter('bool', [
656+
'should' => [
657+
[
658+
'term' => ['__parentPath' => $contextNode->getPath()]
659+
],
660+
[
661+
'term' => ['__path' => $contextNode->getPath()]
662+
]
663+
]
664+
]);
655665

656666
//
657667
// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html

0 commit comments

Comments
 (0)