Skip to content

Commit 6c4bd34

Browse files
committed
TASK: Fix tests by introducing an analyzed version of the title
1 parent 8f95165 commit 6c4bd34

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

Classes/Driver/Version5/Query/FilteredQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception;
1616

1717
/**
18-
* Default Filtered Query
18+
* Filtered query for elastic version 5
1919
*/
2020
class FilteredQuery extends Version1\Query\FilteredQuery
2121
{

Configuration/Testing/NodeTypes.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,14 @@
88
superTypes: []
99

1010
'Flowpack.ElasticSearch.ContentRepositoryAdaptor:Type3':
11-
superTypes: [ 'Flowpack.ElasticSearch.ContentRepositoryAdaptor:Type1', 'Flowpack.ElasticSearch.ContentRepositoryAdaptor:Type2' ]
11+
superTypes: [ 'Flowpack.ElasticSearch.ContentRepositoryAdaptor:Type1', 'Flowpack.ElasticSearch.ContentRepositoryAdaptor:Type2' ]
12+
13+
14+
'TYPO3.Neos:Document':
15+
properties:
16+
title_analyzed:
17+
type: string
18+
search:
19+
elasticSearchMapping:
20+
type: string
21+
index: analyzed

Documentation/ElasticMapping-5.x.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Thus `string` has been split into the new types `text` and `keyword`. Here is a
2121
| "type": "string", "index": "not_analyzed" | "type": "keyword", "index": true |
2222

2323
If no index configuration is set, the default `"type": "keyword", "index": true` is used.
24+
So if you upgrade from previous elasticsearch version, check your node type configurations
25+
if they are configured as expected.
2426

2527
## Conflicting field types
2628

Tests/Functional/Eel/ElasticSearchQueryTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ public function fieldBasedAggregations()
208208
$this->assertEquals($expectedChickenBucket, $result[$aggregationTitle]['buckets'][0]);
209209
}
210210

211+
/**
212+
* @return array
213+
*/
211214
public function termSuggestionDataProvider()
212215
{
213216
return [
@@ -238,13 +241,13 @@ public function termSuggestion($term, $expectedBestSuggestions)
238241
{
239242
$result = $this->getQueryBuilder()
240243
->log($this->getLogMessagePrefix(__METHOD__))
241-
->termSuggestions($term, 'title')
244+
->termSuggestions($term, 'title_analyzed')
242245
->execute()
243246
->getSuggestions();
244247

245-
$this->assertArrayHasKey('suggestions', $result);
248+
$this->assertArrayHasKey('suggestions', $result, 'The result should contain a key suggestions but looks like this ' . print_r($result, 1));
246249
$this->assertTrue(is_array($result['suggestions']), 'Suggestions must be an array.');
247-
$this->assertCount(count($expectedBestSuggestions), $result['suggestions']);
250+
$this->assertCount(count($expectedBestSuggestions), $result['suggestions'], sprintf('Expected %s suggestions "[%s]" but got %s suggestions', count($expectedBestSuggestions), implode(',', $expectedBestSuggestions), print_r($result['suggestions'], 1)));
248251

249252
foreach ($expectedBestSuggestions as $key => $expectedBestSuggestion) {
250253
$suggestion = $result['suggestions'][$key];
@@ -325,12 +328,15 @@ protected function createNodesForNodeSearchTest()
325328
{
326329
$newNode1 = $this->siteNode->createNode('test-node-1', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
327330
$newNode1->setProperty('title', 'chicken');
331+
$newNode1->setProperty('title_analyzed', 'chicken');
328332

329333
$newNode2 = $this->siteNode->createNode('test-node-2', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
330334
$newNode2->setProperty('title', 'chicken');
335+
$newNode2->setProperty('title_analyzed', 'chicken');
331336

332337
$newNode3 = $this->siteNode->createNode('test-node-3', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
333338
$newNode3->setProperty('title', 'egg');
339+
$newNode3->setProperty('title_analyzed', 'egg');
334340

335341
$dimensionContext = $this->contextFactory->create([
336342
'workspaceName' => 'live',

0 commit comments

Comments
 (0)