Skip to content

Commit 6f5d09b

Browse files
committed
Merge branch '3.0' into master
2 parents ca20f64 + cee07e9 commit 6f5d09b

5 files changed

Lines changed: 35 additions & 14 deletions

File tree

Classes/Driver/Version1/IndexerDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function fulltext(NodeInterface $node, array $fulltextIndexOfNode, $targe
114114
[
115115
// first, update the __fulltextParts, then re-generate the __fulltext from all __fulltextParts
116116
'script' => '
117-
if (!ctx._source.containsKey("__fulltextParts")) {
117+
if (!(ctx._source.containsKey("__fulltextParts") && ctx._source.__fulltextParts instanceof Map)) {
118118
ctx._source.__fulltextParts = new LinkedHashMap();
119119
}
120120

Classes/Driver/Version2/IndexerDriver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,19 @@ public function fulltext(NodeInterface $node, array $fulltextIndexOfNode, $targe
123123
'script' => [
124124
'inline' => '
125125
ctx._source.__fulltext = new HashMap();
126-
127-
if (!ctx._source.containsKey("__fulltextParts")) {
126+
127+
if (!(ctx._source.containsKey("__fulltextParts") && ctx._source.__fulltextParts instanceof Map)) {
128128
ctx._source.__fulltextParts = new HashMap();
129129
}
130-
130+
131131
if (nodeIsRemoved || nodeIsHidden || fulltext.size() == 0) {
132132
if (ctx._source.__fulltextParts.containsKey(identifier)) {
133133
ctx._source.__fulltextParts.remove(identifier);
134134
}
135135
} else {
136136
ctx._source.__fulltextParts.put(identifier, fulltext);
137137
}
138-
138+
139139
ctx._source.__fulltextParts.each { originNodeIdentifier, partContent -> partContent.each { bucketKey, content ->
140140
if (ctx._source.__fulltext.containsKey(bucketKey)) {
141141
value = ctx._source.__fulltext[bucketKey] + " " + content.trim();

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

Tests/Functional/Eel/ElasticSearchQueryTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function filterByNodeType()
140140
->log($this->getLogMessagePrefix(__METHOD__))
141141
->nodeType('Neos.NodeTypes:Page')
142142
->count();
143-
$this->assertEquals(3, $resultCount);
143+
$this->assertEquals(4, $resultCount);
144144
}
145145

146146
/**
@@ -166,7 +166,7 @@ public function limitDoesNotImpactCount()
166166
->limit(1);
167167

168168
$resultCount = $query->count();
169-
$this->assertEquals(3, $resultCount, 'Asserting the count query returns the total count.');
169+
$this->assertEquals(4, $resultCount, 'Asserting the count query returns the total count.');
170170
}
171171

172172
/**
@@ -198,7 +198,7 @@ public function fieldBasedAggregations()
198198

199199
$this->assertArrayHasKey($aggregationTitle, $result);
200200

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

203203
$expectedChickenBucket = [
204204
'key' => 'chicken',
@@ -268,13 +268,13 @@ public function nodesWillBeSortedDesc()
268268
/** @var QueryResultInterface $result $node */
269269

270270
$this->assertInstanceOf(QueryResultInterface::class, $result);
271-
$this->assertCount(3, $result, 'The result should have 3 items');
272-
$this->assertEquals(3, $result->count(), 'Count should be 3');
271+
$this->assertCount(4, $result, 'The result should have 3 items');
272+
$this->assertEquals(4, $result->count(), 'Count should be 3');
273273

274274
$node = $result->getFirst();
275275

276276
$this->assertInstanceOf(NodeInterface::class, $node);
277-
$this->assertEquals('egg', $node->getProperty('title'), 'Asserting a desc sort order by property title');
277+
$this->assertEquals('welcome', $node->getProperty('title'), 'Asserting a desc sort order by property title');
278278
}
279279

280280
/**

Tests/Unit/Eel/ElasticSearchQueryBuilderTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,19 @@ public function basicRequestStructureTakesContextNodeIntoAccount()
111111
'bool' => [
112112
'must' => [
113113
0 => [
114-
'term' => [
115-
'__parentPath' => '/foo/bar'
114+
'bool' => [
115+
'should' => [
116+
0 => [
117+
'term' => [
118+
'__parentPath' => '/foo/bar'
119+
]
120+
],
121+
1 => [
122+
'term' => [
123+
'__path' => '/foo/bar'
124+
]
125+
]
126+
]
116127
]
117128
],
118129
1 => [

0 commit comments

Comments
 (0)