Skip to content

Commit 8f95165

Browse files
committed
TASK: Set default mapping for string fields to keyword
1 parent 3eadce2 commit 8f95165

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

Classes/Driver/Version5/Mapping/NodeTypeMappingBuilder.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
* source code.
1212
*/
1313

14+
use TYPO3\Flow\Annotations as Flow;
1415
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\Version2;
1516
use Flowpack\ElasticSearch\Domain\Model\Index;
1617
use Flowpack\ElasticSearch\Domain\Model\Mapping;
1718
use Flowpack\ElasticSearch\Mapping\MappingCollection;
18-
use TYPO3\Flow\Annotations as Flow;
1919
use TYPO3\Flow\Error\Result;
2020
use TYPO3\Flow\Error\Warning;
2121
use TYPO3\Flow\Object\ObjectManagerInterface;
2222
use TYPO3\TYPO3CR\Domain\Model\NodeType;
2323

2424
/**
25-
* NodeTypeMappingBuilder for Elasticsearch version 2.x
25+
* NodeTypeMappingBuilder for Elasticsearch version 5.x
2626
*
2727
* @Flow\Scope("singleton")
2828
*/
@@ -111,7 +111,7 @@ public function buildMappingInformation(Index $index)
111111
* | 2.x | 5.x |
112112
* |-------------------------------------------|----------------------------------|
113113
* | "type": "string", "index": "no" | "type": "text", "index": false |
114-
* | "type": "string"[, "index": "analyzed"] | "type": "text", "index": true |
114+
* | "type": "string", "index": "analyzed" | "type": "text", "index": true |
115115
* | "type": "string", "index": "not_analyzed" | "type": "keyword", "index": true |
116116
*
117117
* @param array &$mapping
@@ -132,9 +132,12 @@ protected function adjustStringTypeMapping(array &$mapping)
132132
} elseif (isset($item['index']) && $item['index'] === 'no') {
133133
$item['type'] = 'text';
134134
$item['index'] = false;
135-
} else {
135+
} elseif (isset($item['index']) && $item['index'] === 'analyzed') {
136136
$item['type'] = 'text';
137137
$item['index'] = true;
138+
} else {
139+
$item['type'] = 'keyword';
140+
$item['index'] = true;
138141
}
139142
}
140143

Documentation/ElasticMapping-5.x.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ Thus `string` has been split into the new types `text` and `keyword`. Here is a
1717
| 2.x | 5.x |
1818
|-------------------------------------------|----------------------------------|
1919
| "type": "string", "index": "no" | "type": "text", "index": false |
20-
| "type": "string"[, "index": "analyzed"] | "type": "text", "index": true |
20+
| "type": "string", "index": "analyzed" | "type": "text", "index": true |
2121
| "type": "string", "index": "not_analyzed" | "type": "keyword", "index": true |
2222

23+
If no index configuration is set, the default `"type": "keyword", "index": true` is used.
24+
2325
## Conflicting field types
2426

2527
Something that has been enforced since version 2 of Elasticsearch is the fact

0 commit comments

Comments
 (0)