Skip to content

Commit a5d04f6

Browse files
authored
Merge pull request #149 from dfeyer/bugfix-get-current-document
BUGFIX: Include the context document in the query result
2 parents b76cf49 + e343201 commit a5d04f6

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Eel/ElasticSearchQueryBuilder.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,16 @@ public function query(NodeInterface $contextNode)
777777
// on indexing, the __parentPath is tokenized to contain ALL parent path parts,
778778
// e.g. /foo, /foo/bar/, /foo/bar/baz; to speed up matching.. That's why we use a simple "term" filter here.
779779
// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-filter.html
780-
$this->queryFilter('term', ['__parentPath' => $contextNode->getPath()]);
780+
$this->queryFilter('bool', [
781+
'should' => [
782+
[
783+
'term' => ['__parentPath' => $contextNode->getPath()]
784+
],
785+
[
786+
'term' => ['__path' => $contextNode->getPath()]
787+
]
788+
]
789+
]);
781790

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

Tests/Functional/Eel/ElasticSearchQueryTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function filterByNodeType()
125125
->log($this->getLogMessagePrefix(__METHOD__))
126126
->nodeType('TYPO3.Neos.NodeTypes:Page')
127127
->count();
128-
$this->assertEquals(3, $resultCount);
128+
$this->assertEquals(4, $resultCount);
129129
}
130130

131131
/**
@@ -151,7 +151,7 @@ public function limitDoesNotImpactCount()
151151
->limit(1);
152152

153153
$resultCount = $query->count();
154-
$this->assertEquals(3, $resultCount, 'Asserting the count query returns the total count.');
154+
$this->assertEquals(4, $resultCount, 'Asserting the count query returns the total count.');
155155
}
156156

157157
/**
@@ -183,7 +183,7 @@ public function fieldBasedAggregations()
183183

184184
$this->assertArrayHasKey($aggregationTitle, $result);
185185

186-
$this->assertCount(2, $result[$aggregationTitle]['buckets']);
186+
$this->assertCount(3, $result[$aggregationTitle]['buckets']);
187187

188188
$expectedChickenBucket = [
189189
'key' => 'chicken',
@@ -227,13 +227,13 @@ public function nodesWillBeSortedDesc()
227227
/** @var QueryResultInterface $result $node */
228228

229229
$this->assertInstanceOf(QueryResultInterface::class, $result);
230-
$this->assertCount(3, $result, 'The result should have 3 items');
231-
$this->assertEquals(3, $result->count(), 'Count should be 3');
230+
$this->assertCount(4, $result, 'The result should have 4 items');
231+
$this->assertEquals(4, $result->count(), 'Count should be 4');
232232

233233
$node = $result->getFirst();
234234

235235
$this->assertInstanceOf(NodeInterface::class, $node);
236-
$this->assertEquals('egg', $node->getProperty('title'), 'Asserting a desc sort order by property title');
236+
$this->assertEquals('welcome', $node->getProperty('title'), 'Asserting a desc sort order by property title');
237237
}
238238

239239
/**

Tests/Unit/Eel/ElasticSearchQueryBuilderTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,19 @@ public function basicRequestStructureTakesContextNodeIntoAccount()
6464
'bool' => [
6565
'must' => [
6666
0 => [
67-
'term' => [
68-
'__parentPath' => '/foo/bar'
67+
'bool' => [
68+
'should' => [
69+
0 => [
70+
'term' => [
71+
'__parentPath' => '/foo/bar'
72+
]
73+
],
74+
1 => [
75+
'term' => [
76+
'__path' => '/foo/bar'
77+
]
78+
]
79+
]
6980
]
7081
],
7182
1 => [

0 commit comments

Comments
 (0)