From f751ddb8b1cc513c1064360c2c73abdb38d5c33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20FOUCRET?= Date: Wed, 7 Feb 2018 08:58:40 +0100 Subject: [PATCH] Replace deprecated string fields with text and keywords. --- .../Helper/AbstractAttribute.php | 4 +- .../Datasource/AbstractAttributeData.php | 3 +- .../Model/Layer/Filter/Boolean.php | 2 +- .../Unit/Helper/AbstractAttributeTest.php | 4 +- .../etc/elasticsuite_indices.xml | 12 ++-- .../Api/Index/Mapping/FieldInterface.php | 18 +----- .../Index/Mapping.php | 4 +- .../Index/Mapping/Field.php | 16 ++--- .../Request/SortOrder/Builder.php | 2 +- .../Query/Fulltext/SearchableFieldFilter.php | 2 +- .../Test/Unit/Index/Mapping/FieldTest.php | 17 +++-- .../Test/Unit/Index/MappingTest.php | 30 ++++----- .../Request/SortOrder/BuilderTest.php | 6 +- .../Aggregation/AggregationBuilderTest.php | 10 +-- .../Request/Query/Filter/QueryBuilderTest.php | 6 +- .../Query/Fulltext/QueryBuilderTest.php | 8 +-- .../etc/elasticsuite_indices.xml | 62 +++++++++---------- 17 files changed, 97 insertions(+), 109 deletions(-) diff --git a/src/module-elasticsuite-catalog/Helper/AbstractAttribute.php b/src/module-elasticsuite-catalog/Helper/AbstractAttribute.php index a46f18507..ee2c85316 100644 --- a/src/module-elasticsuite-catalog/Helper/AbstractAttribute.php +++ b/src/module-elasticsuite-catalog/Helper/AbstractAttribute.php @@ -111,7 +111,7 @@ public function getMappingFieldOptions(AttributeInterface $attribute) */ public function getFieldType(AttributeInterface $attribute) { - $type = FieldInterface::FIELD_TYPE_STRING; + $type = FieldInterface::FIELD_TYPE_TEXT; if ($attribute->getSourceModel() == 'Magento\Eav\Model\Entity\Attribute\Source\Boolean') { $type = FieldInterface::FIELD_TYPE_BOOLEAN; @@ -124,7 +124,7 @@ public function getFieldType(AttributeInterface $attribute) } elseif ($attribute->getBackendType() == 'datetime') { $type = FieldInterface::FIELD_TYPE_DATE; } elseif ($attribute->usesSource() && $attribute->getSourceModel() === null) { - $type = FieldInterface::FIELD_TYPE_INTEGER; + $type = $attribute->getSourceModel() ? FieldInterface::FIELD_TYPE_INTEGER : FieldInterface::FIELD_TYPE_KEYWORD; } return $type; diff --git a/src/module-elasticsuite-catalog/Model/Eav/Indexer/Fulltext/Datasource/AbstractAttributeData.php b/src/module-elasticsuite-catalog/Model/Eav/Indexer/Fulltext/Datasource/AbstractAttributeData.php index 0efd816c6..f6ae5c842 100644 --- a/src/module-elasticsuite-catalog/Model/Eav/Indexer/Fulltext/Datasource/AbstractAttributeData.php +++ b/src/module-elasticsuite-catalog/Model/Eav/Indexer/Fulltext/Datasource/AbstractAttributeData.php @@ -17,6 +17,7 @@ use Smile\ElasticsuiteCatalog\Model\ResourceModel\Eav\Indexer\Fulltext\Datasource\AbstractAttributeData as ResourceModel; use Smile\ElasticsuiteCore\Index\Mapping\FieldFactory; use Smile\ElasticsuiteCatalog\Helper\AbstractAttribute as AttributeHelper; +use Smile\ElasticsuiteCore\Api\Index\Mapping\FieldInterface; /** * Abstract Datasource for EAV entities @@ -178,7 +179,7 @@ private function initField(AttributeInterface $attribute) if ($attribute->usesSource()) { $optionFieldName = $this->attributeHelper->getOptionTextFieldName($fieldName); - $fieldType = 'string'; + $fieldType = FieldInterface::FIELD_TYPE_TEXT; $fieldOptions = ['name' => $optionFieldName, 'type' => $fieldType, 'fieldConfig' => $fieldConfig]; $this->fields[$optionFieldName] = $this->fieldFactory->create($fieldOptions); diff --git a/src/module-elasticsuite-catalog/Model/Layer/Filter/Boolean.php b/src/module-elasticsuite-catalog/Model/Layer/Filter/Boolean.php index 1873e95a4..833f824db 100644 --- a/src/module-elasticsuite-catalog/Model/Layer/Filter/Boolean.php +++ b/src/module-elasticsuite-catalog/Model/Layer/Filter/Boolean.php @@ -26,7 +26,7 @@ class Boolean extends Attribute */ public function apply(\Magento\Framework\App\RequestInterface $request) { - $attributeValue = $request->getParam($this->_requestVar); + $attributeValue = (bool) $request->getParam($this->_requestVar); if (!empty($attributeValue)) { if (!is_array($attributeValue)) { diff --git a/src/module-elasticsuite-catalog/Test/Unit/Helper/AbstractAttributeTest.php b/src/module-elasticsuite-catalog/Test/Unit/Helper/AbstractAttributeTest.php index cf1ee1bcb..5c7b8ba6f 100644 --- a/src/module-elasticsuite-catalog/Test/Unit/Helper/AbstractAttributeTest.php +++ b/src/module-elasticsuite-catalog/Test/Unit/Helper/AbstractAttributeTest.php @@ -65,7 +65,9 @@ public function attributeTypeProvider() ['varchar', false, null, 'validate-number', FieldInterface::FIELD_TYPE_DOUBLE], ['datetime', false, null, null, FieldInterface::FIELD_TYPE_DATE], ['varchar', true, null, null, FieldInterface::FIELD_TYPE_INTEGER], - ['varchar', false, null, null, FieldInterface::FIELD_TYPE_STRING], + ['varchar', false, null, null, FieldInterface::FIELD_TYPE_TEXT], + ['varchar', true, null, null, FieldInterface::FIELD_TYPE_INTEGER], + ['varchar', true, 'sourceModel', null, FieldInterface::FIELD_TYPE_KEYWORD], ]; } } diff --git a/src/module-elasticsuite-catalog/etc/elasticsuite_indices.xml b/src/module-elasticsuite-catalog/etc/elasticsuite_indices.xml index 11f8afadb..f21cff7ad 100644 --- a/src/module-elasticsuite-catalog/etc/elasticsuite_indices.xml +++ b/src/module-elasticsuite-catalog/etc/elasticsuite_indices.xml @@ -36,16 +36,16 @@ - - + + 1 1 whitespace - - + + @@ -61,7 +61,7 @@ - + 1 1 0 @@ -87,7 +87,7 @@ - + diff --git a/src/module-elasticsuite-core/Api/Index/Mapping/FieldInterface.php b/src/module-elasticsuite-core/Api/Index/Mapping/FieldInterface.php index 9061305b3..de999e1c9 100644 --- a/src/module-elasticsuite-core/Api/Index/Mapping/FieldInterface.php +++ b/src/module-elasticsuite-core/Api/Index/Mapping/FieldInterface.php @@ -25,31 +25,17 @@ interface FieldInterface { /** * Field types declaration. - * */ + const FIELD_TYPE_TEXT = 'text'; + const FIELD_TYPE_KEYWORD = 'keyword'; const FIELD_TYPE_DOUBLE = 'double'; const FIELD_TYPE_INTEGER = 'integer'; const FIELD_TYPE_LONG = 'long'; const FIELD_TYPE_DATE = 'date'; const FIELD_TYPE_BOOLEAN = 'boolean'; const FIELD_TYPE_NESTED = 'nested'; - const FIELD_TYPE_OBJECT = 'object'; - /** - * Deprecated multi_field type. - * - * @deprecated - */ - const FIELD_TYPE_MULTI = 'multi_field'; - - /** - * Deprecated string type. - * - * @deprecated - */ - const FIELD_TYPE_STRING = 'string'; - /** * Analyzers declarations. */ diff --git a/src/module-elasticsuite-core/Index/Mapping.php b/src/module-elasticsuite-core/Index/Mapping.php index 89d64bacd..5606810c8 100644 --- a/src/module-elasticsuite-core/Index/Mapping.php +++ b/src/module-elasticsuite-core/Index/Mapping.php @@ -107,7 +107,7 @@ public function getProperties() $properties = []; foreach ($this->defaultMappingFields as $fieldName => $analyzers) { - $properties = $this->addProperty($properties, $fieldName, FieldInterface::FIELD_TYPE_STRING, $analyzers); + $properties = $this->addProperty($properties, $fieldName, FieldInterface::FIELD_TYPE_TEXT, $analyzers); } foreach ($this->getFields() as $currentField) { @@ -262,7 +262,7 @@ private function getDynamicFields(array $dynamicFieldProviders) */ private function addProperty(array $properties, $propertyName, $propertyType, $analyzers = []) { - $property = ['type' => FieldInterface::FIELD_TYPE_STRING, 'analyzer' => FieldInterface::ANALYZER_STANDARD]; + $property = ['type' => $propertyType, 'analyzer' => FieldInterface::ANALYZER_STANDARD]; foreach ($analyzers as $analyzer) { if ($analyzer !== FieldInterface::ANALYZER_STANDARD) { diff --git a/src/module-elasticsuite-core/Index/Mapping/Field.php b/src/module-elasticsuite-core/Index/Mapping/Field.php index 7cfe0946a..c96a55a89 100644 --- a/src/module-elasticsuite-core/Index/Mapping/Field.php +++ b/src/module-elasticsuite-core/Index/Mapping/Field.php @@ -73,7 +73,7 @@ class Field implements FieldInterface * @param array $fieldConfig Field configuration (see self::$config declaration for * available values and default values). */ - public function __construct($name, $type = 'string', $nestedPath = null, $fieldConfig = []) + public function __construct($name, $type = self::FIELD_TYPE_KEYWORD, $nestedPath = null, $fieldConfig = []) { $this->name = (string) $name; $this->type = (string) $type; @@ -179,7 +179,7 @@ public function getMappingPropertyConfig() { $property = $this->getPropertyConfig(); - if ($this->getType() == self::FIELD_TYPE_STRING) { + if ($this->getType() == self::FIELD_TYPE_TEXT) { $analyzers = $this->getFieldAnalyzers(); $property = $this->getPropertyConfig(current($analyzers)); @@ -237,12 +237,12 @@ private function checkAnalyzer($property, $expectedAnalyzer) { $isAnalyzerCorrect = true; - if ($property['type'] == self::FIELD_TYPE_STRING) { + if ($property['type'] == self::FIELD_TYPE_TEXT || $property['type'] == self::FIELD_TYPE_KEYWORD) { $isAnalyzed = $expectedAnalyzer !== self::ANALYZER_UNTOUCHED; if ($isAnalyzed && (!isset($property['analyzer']) || $property['analyzer'] != $expectedAnalyzer)) { $isAnalyzerCorrect = false; - } elseif (!$isAnalyzed && (!isset($property['index']) || $property['index'] != 'not_analyzed')) { + } elseif (!$isAnalyzed && $property['type'] !== self::FIELD_TYPE_KEYWORD) { $isAnalyzerCorrect = false; } } @@ -319,11 +319,11 @@ private function getFieldAnalyzers() */ private function getPropertyConfig($analyzer = self::ANALYZER_UNTOUCHED) { - $fieldMapping = ['type' => $this->getType(), 'doc_values' => true]; + $fieldMapping = ['type' => $this->getType()]; - if ($this->getType() == self::FIELD_TYPE_STRING && $analyzer == self::ANALYZER_UNTOUCHED) { - $fieldMapping['index'] = 'not_analyzed'; - } elseif ($this->getType() == self::FIELD_TYPE_STRING) { + if ($this->getType() == self::FIELD_TYPE_TEXT && $analyzer == self::ANALYZER_UNTOUCHED) { + $fieldMapping['type'] = self::FIELD_TYPE_KEYWORD; + } elseif ($this->getType() == self::FIELD_TYPE_TEXT) { $fieldMapping['analyzer'] = $analyzer; $fieldMapping['doc_values'] = false; $fieldMapping['index_options'] = 'docs'; diff --git a/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Request/SortOrder/Builder.php b/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Request/SortOrder/Builder.php index 78ddc5c9f..4266302ac 100644 --- a/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Request/SortOrder/Builder.php +++ b/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Request/SortOrder/Builder.php @@ -71,7 +71,7 @@ private function buildSortOrder(SortOrderInterface $sortOrder) if ($sortField !== SortOrderInterface::DEFAULT_SORT_FIELD) { $sortOrderConfig['missing'] = $sortOrder->getDirection() == SortOrderInterface::SORT_ASC ? '_last' : '_first'; - $sortOrderConfig['unmapped_type'] = FieldInterface::FIELD_TYPE_STRING; + $sortOrderConfig['unmapped_type'] = FieldInterface::FIELD_TYPE_KEYWORD; } if ($sortOrder->getType() == SortOrderInterface::TYPE_NESTED) { diff --git a/src/module-elasticsuite-core/Search/Request/Query/Fulltext/SearchableFieldFilter.php b/src/module-elasticsuite-core/Search/Request/Query/Fulltext/SearchableFieldFilter.php index adc2b27b6..f04bc031b 100644 --- a/src/module-elasticsuite-core/Search/Request/Query/Fulltext/SearchableFieldFilter.php +++ b/src/module-elasticsuite-core/Search/Request/Query/Fulltext/SearchableFieldFilter.php @@ -31,6 +31,6 @@ class SearchableFieldFilter implements FieldFilterInterface */ public function filterField(FieldInterface $field) { - return $field->getType() == FieldInterface::FIELD_TYPE_STRING && $field->isSearchable() && $field->isNested() === false; + return $field->getType() == FieldInterface::FIELD_TYPE_TEXT && $field->isSearchable() && $field->isNested() === false; } } diff --git a/src/module-elasticsuite-core/Test/Unit/Index/Mapping/FieldTest.php b/src/module-elasticsuite-core/Test/Unit/Index/Mapping/FieldTest.php index 9aa472fe2..2f6d7117d 100644 --- a/src/module-elasticsuite-core/Test/Unit/Index/Mapping/FieldTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Index/Mapping/FieldTest.php @@ -36,7 +36,7 @@ public function testDefaultValues() $field = new Field('fieldName'); $this->assertEquals('fieldName', $field->getName()); - $this->assertEquals(FieldInterface::FIELD_TYPE_STRING, $field->getType()); + $this->assertEquals(FieldInterface::FIELD_TYPE_KEYWORD, $field->getType()); $this->assertEquals(false, $field->isSearchable()); $this->assertEquals(1, $field->getSearchWeight()); $this->assertEquals(true, $field->isFilterable()); @@ -47,7 +47,7 @@ public function testDefaultValues() $this->assertEquals(null, $field->getNestedPath()); $mappingPropertyConfig = $field->getMappingPropertyConfig(); - $this->assertEquals(FieldInterface::FIELD_TYPE_STRING, $mappingPropertyConfig['type']); + $this->assertEquals(FieldInterface::FIELD_TYPE_KEYWORD, $mappingPropertyConfig['type']); $this->assertEquals('fieldName', $field->getMappingProperty()); $this->assertEquals(null, $field->getMappingProperty(FieldInterface::ANALYZER_STANDARD)); } @@ -59,7 +59,7 @@ public function testDefaultValues() */ public function testNestedField() { - $field = new Field('parent.child', FieldInterface::FIELD_TYPE_STRING, 'parent', ['is_searchable' => true]); + $field = new Field('parent.child', FieldInterface::FIELD_TYPE_TEXT, 'parent', ['is_searchable' => true]); $this->assertEquals(true, $field->isNested()); $this->assertEquals('parent', $field->getNestedPath()); @@ -80,7 +80,7 @@ public function testNestedField() */ public function testInvalidNestedField() { - new Field('parent.child', FieldInterface::FIELD_TYPE_STRING, 'invalidparent'); + new Field('parent.child', FieldInterface::FIELD_TYPE_TEXT, 'invalidparent'); } /** @@ -104,7 +104,6 @@ public function testBasicTypes() $mappingPropertyConfig = $field->getMappingPropertyConfig(); $this->assertEquals($type, $mappingPropertyConfig['type']); - $this->assertEquals(true, $mappingPropertyConfig['doc_values']); if ($type === FieldInterface::FIELD_TYPE_DATE) { $this->assertEquals('yyyy-MM-dd HH:mm:ss||yyyy-MM-dd', $mappingPropertyConfig['format']); @@ -122,11 +121,11 @@ public function testBasicTypes() public function testComplexSearchableStringField() { $fieldConfig = ['is_searchable' => true, 'is_used_for_sort_by' => true, 'search_weight' => 2]; - $fieldType = FieldInterface::FIELD_TYPE_STRING; + $fieldType = FieldInterface::FIELD_TYPE_TEXT; $field = new Field('field', $fieldType, null, $fieldConfig); $mappingPropertyConfig = $field->getMappingPropertyConfig(); - $this->assertEquals(FieldInterface::FIELD_TYPE_STRING, $mappingPropertyConfig['type']); + $this->assertEquals(FieldInterface::FIELD_TYPE_TEXT, $mappingPropertyConfig['type']); $this->assertEquals(FieldInterface::ANALYZER_STANDARD, $mappingPropertyConfig['analyzer']); $this->assertEquals(FieldInterface::ANALYZER_WHITESPACE, $mappingPropertyConfig['fields']['whitespace']['analyzer']); @@ -148,11 +147,11 @@ public function testComplexSearchableStringField() public function testSimpleSearchableStringField() { $fieldConfig = ['is_searchable' => true, 'is_filterable' => false, 'search_weight' => 1]; - $fieldType = FieldInterface::FIELD_TYPE_STRING; + $fieldType = FieldInterface::FIELD_TYPE_TEXT; $field = new Field('field', $fieldType, null, $fieldConfig); $mappingPropertyConfig = $field->getMappingPropertyConfig(); - $this->assertEquals(FieldInterface::FIELD_TYPE_STRING, $mappingPropertyConfig['type']); + $this->assertEquals(FieldInterface::FIELD_TYPE_TEXT, $mappingPropertyConfig['type']); $this->assertEquals(null, $field->getMappingProperty()); $this->assertEquals('field', $field->getMappingProperty(FieldInterface::ANALYZER_STANDARD)); diff --git a/src/module-elasticsuite-core/Test/Unit/Index/MappingTest.php b/src/module-elasticsuite-core/Test/Unit/Index/MappingTest.php index 036b35710..0bd9d54f4 100644 --- a/src/module-elasticsuite-core/Test/Unit/Index/MappingTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Index/MappingTest.php @@ -46,16 +46,16 @@ protected function setUp() // Static fields. $fields = [ new Field('entity_id', FieldInterface::FIELD_TYPE_INTEGER), - new Field('nested.child1', FieldInterface::FIELD_TYPE_STRING, 'nested'), - new Field('nested.child2', FieldInterface::FIELD_TYPE_STRING, 'nested'), - new Field('object.child1', FieldInterface::FIELD_TYPE_STRING), - new Field('object.child2', FieldInterface::FIELD_TYPE_STRING), + new Field('nested.child1', FieldInterface::FIELD_TYPE_TEXT, 'nested'), + new Field('nested.child2', FieldInterface::FIELD_TYPE_TEXT, 'nested'), + new Field('object.child1', FieldInterface::FIELD_TYPE_TEXT), + new Field('object.child2', FieldInterface::FIELD_TYPE_TEXT), ]; // Stubing a dynanyc data provider. $dynamicDataProvider = $this->getMockBuilder(DynamicFieldProviderInterface::class)->getMock(); $dynamicDataProviderFields = [ - new Field('title', FieldInterface::FIELD_TYPE_STRING, null, ['is_searchable' => true]), + new Field('title', FieldInterface::FIELD_TYPE_TEXT, null, ['is_searchable' => true]), ]; $dynamicDataProvider->method('getFields') ->will($this->returnValue($dynamicDataProviderFields)); @@ -74,7 +74,7 @@ public function testDefaultSearchProperty() $properties = $this->mapping->getProperties(); $this->assertArrayHasKey(Mapping::DEFAULT_SEARCH_FIELD, $properties); - $this->assertEquals(FieldInterface::FIELD_TYPE_STRING, $properties[Mapping::DEFAULT_SEARCH_FIELD]['type']); + $this->assertEquals(FieldInterface::FIELD_TYPE_TEXT, $properties[Mapping::DEFAULT_SEARCH_FIELD]['type']); $this->assertArrayHasKey(FieldInterface::ANALYZER_WHITESPACE, $properties[Mapping::DEFAULT_SEARCH_FIELD]['fields']); $this->assertArrayHasKey(FieldInterface::ANALYZER_SHINGLE, $properties[Mapping::DEFAULT_SEARCH_FIELD]['fields']); } @@ -89,7 +89,7 @@ public function testDefaultAutocompleteProperty() $properties = $this->mapping->getProperties(); $this->assertArrayHasKey(Mapping::DEFAULT_AUTOCOMPLETE_FIELD, $properties); - $this->assertEquals(FieldInterface::FIELD_TYPE_STRING, $properties[Mapping::DEFAULT_AUTOCOMPLETE_FIELD]['type']); + $this->assertEquals(FieldInterface::FIELD_TYPE_TEXT, $properties[Mapping::DEFAULT_AUTOCOMPLETE_FIELD]['type']); $this->assertArrayHasKey(FieldInterface::ANALYZER_WHITESPACE, $properties[Mapping::DEFAULT_AUTOCOMPLETE_FIELD]['fields']); $this->assertArrayHasKey(FieldInterface::ANALYZER_SHINGLE, $properties[Mapping::DEFAULT_AUTOCOMPLETE_FIELD]['fields']); } @@ -104,7 +104,7 @@ public function testDefaultSpellingProperty() $properties = $this->mapping->getProperties(); $this->assertArrayHasKey(Mapping::DEFAULT_SPELLING_FIELD, $properties); - $this->assertEquals(FieldInterface::FIELD_TYPE_STRING, $properties[Mapping::DEFAULT_SPELLING_FIELD]['type']); + $this->assertEquals(FieldInterface::FIELD_TYPE_TEXT, $properties[Mapping::DEFAULT_SPELLING_FIELD]['type']); $this->assertArrayHasKey(FieldInterface::ANALYZER_WHITESPACE, $properties[Mapping::DEFAULT_SPELLING_FIELD]['fields']); $this->assertArrayHasKey(FieldInterface::ANALYZER_SHINGLE, $properties[Mapping::DEFAULT_SPELLING_FIELD]['fields']); $this->assertArrayHasKey(FieldInterface::ANALYZER_PHONETIC, $properties[Mapping::DEFAULT_SPELLING_FIELD]['fields']); @@ -278,40 +278,40 @@ private function getSearchWeightedMapping() ), new Field( 'ignoredField', - FieldInterface::FIELD_TYPE_STRING + FieldInterface::FIELD_TYPE_TEXT ), new Field( 'standardField', - FieldInterface::FIELD_TYPE_STRING, + FieldInterface::FIELD_TYPE_TEXT, null, ['is_searchable' => true] ), new Field( 'weightedField', - FieldInterface::FIELD_TYPE_STRING, + FieldInterface::FIELD_TYPE_TEXT, null, ['is_searchable' => true, 'search_weight' => 2] ), new Field( 'whitespaceField', - FieldInterface::FIELD_TYPE_STRING, + FieldInterface::FIELD_TYPE_TEXT, null, ['is_searchable' => true, 'search_weight' => 1, 'default_search_analyzer' => Field::ANALYZER_WHITESPACE] ), new Field( 'whitespaceWeightedField', - FieldInterface::FIELD_TYPE_STRING, + FieldInterface::FIELD_TYPE_TEXT, null, ['is_searchable' => true, 'search_weight' => 2, 'default_search_analyzer' => Field::ANALYZER_WHITESPACE] ), new Field( 'nested.subfield', - FieldInterface::FIELD_TYPE_STRING, + FieldInterface::FIELD_TYPE_TEXT, 'nested' ), new Field( 'object.subfield', - FieldInterface::FIELD_TYPE_STRING + FieldInterface::FIELD_TYPE_TEXT ), ]; diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/SortOrder/BuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/SortOrder/BuilderTest.php index 7e6ec4dd7..4828eb162 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/SortOrder/BuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Adapter/Elasticsuite/Request/SortOrder/BuilderTest.php @@ -50,7 +50,7 @@ public function testSimpleSortOrder() $this->assertArrayHasKey('field', $currentSortOrder); $this->assertEquals(StandardSortOrder::SORT_ASC, $currentSortOrder['field']['order']); $this->assertEquals('_last', $currentSortOrder['field']['missing']); - $this->assertEquals(FieldInterface::FIELD_TYPE_STRING, $currentSortOrder['field']['unmapped_type']); + $this->assertEquals(FieldInterface::FIELD_TYPE_KEYWORD, $currentSortOrder['field']['unmapped_type']); } /** @@ -109,7 +109,7 @@ public function testNestedSortOrder() $this->assertArrayHasKey('parent.child', $currentSortOrder); $this->assertEquals(StandardSortOrder::SORT_ASC, $currentSortOrder['parent.child']['order']); $this->assertEquals('_last', $currentSortOrder['parent.child']['missing']); - $this->assertEquals(FieldInterface::FIELD_TYPE_STRING, $currentSortOrder['parent.child']['unmapped_type']); + $this->assertEquals(FieldInterface::FIELD_TYPE_KEYWORD, $currentSortOrder['parent.child']['unmapped_type']); $this->assertEquals('parent', $currentSortOrder['parent.child']['nested_path']); $this->assertEquals(NestedSortOrder::SCORE_MODE_MIN, $currentSortOrder['parent.child']['mode']); } @@ -133,7 +133,7 @@ public function testNestedFilterSortOrder() $this->assertArrayHasKey('parent.child', $currentSortOrder); $this->assertEquals(StandardSortOrder::SORT_ASC, $currentSortOrder['parent.child']['order']); $this->assertEquals('_last', $currentSortOrder['parent.child']['missing']); - $this->assertEquals(FieldInterface::FIELD_TYPE_STRING, $currentSortOrder['parent.child']['unmapped_type']); + $this->assertEquals(FieldInterface::FIELD_TYPE_KEYWORD, $currentSortOrder['parent.child']['unmapped_type']); $this->assertEquals('parent', $currentSortOrder['parent.child']['nested_path']); $this->assertEquals(NestedSortOrder::SCORE_MODE_MIN, $currentSortOrder['parent.child']['mode']); $this->assertEquals('query', $currentSortOrder['parent.child']['nested_filter']); diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationBuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationBuilderTest.php index 74a6cdbc2..98d49c370 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationBuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Request/Aggregation/AggregationBuilderTest.php @@ -261,11 +261,11 @@ private function getMapping() { $fields = [ new Field('entity_id', Field::FIELD_TYPE_INTEGER), - new Field('simpleField', Field::FIELD_TYPE_STRING), - new Field('searchableField', Field::FIELD_TYPE_STRING, null, ['is_searchable' => true]), - new Field('nested.simpleField', Field::FIELD_TYPE_STRING, 'nested'), - new Field('nested.searchableField', Field::FIELD_TYPE_STRING, 'nested', ['is_searchable' => true]), - new Field('notFilterableField', Field::FIELD_TYPE_STRING, null, ['is_filterable' => false, 'is_searchable' => true]), + new Field('simpleField', Field::FIELD_TYPE_KEYWORD), + new Field('searchableField', Field::FIELD_TYPE_TEXT, null, ['is_searchable' => true]), + new Field('nested.simpleField', Field::FIELD_TYPE_KEYWORD, 'nested'), + new Field('nested.searchableField', Field::FIELD_TYPE_TEXT, 'nested', ['is_searchable' => true]), + new Field('notFilterableField', Field::FIELD_TYPE_TEXT, null, ['is_filterable' => false, 'is_searchable' => true]), ]; return new Mapping('entity_id', $fields); diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Filter/QueryBuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Filter/QueryBuilderTest.php index 944c0ccae..ba96222fe 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Filter/QueryBuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Filter/QueryBuilderTest.php @@ -55,9 +55,9 @@ public function __construct($name = null, array $data = array(), $dataName = '') $this->fields = [ new Field('idField', 'integer'), - new Field('simpleTextField', 'string'), - new Field('analyzedField', 'string', null, ['is_searchable' => true, 'is_filterable' => false]), - new Field('nested.child', 'string', 'nested'), + new Field('simpleTextField', Field::FIELD_TYPE_KEYWORD), + new Field('analyzedField', Field::FIELD_TYPE_TEXT, null, ['is_searchable' => true, 'is_filterable' => false]), + new Field('nested.child', Field::FIELD_TYPE_KEYWORD, 'nested'), ]; } diff --git a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Fulltext/QueryBuilderTest.php b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Fulltext/QueryBuilderTest.php index 90854cfa0..769d81013 100644 --- a/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Fulltext/QueryBuilderTest.php +++ b/src/module-elasticsuite-core/Test/Unit/Search/Request/Query/Fulltext/QueryBuilderTest.php @@ -61,10 +61,10 @@ public function __construct($name = null, array $data = array(), $dataName = '') parent::__construct($name, $data, $dataName); $this->fields = [ - new Field('idField', 'integer'), - new Field('fulltextSearch1', 'string', null, ['is_searchable' => true]), - new Field('fulltextSearch2', 'string', null, ['is_searchable' => true, 'is_filterable' => false]), - new Field('fulltextSearch3', 'string', null, ['is_searchable' => true, 'is_used_in_spellcheck' => true]), + new Field('idField', Field::FIELD_TYPE_INTEGER), + new Field('fulltextSearch1', Field::FIELD_TYPE_TEXT, null, ['is_searchable' => true]), + new Field('fulltextSearch2', Field::FIELD_TYPE_TEXT, null, ['is_searchable' => true, 'is_filterable' => false]), + new Field('fulltextSearch3', Field::FIELD_TYPE_TEXT, null, ['is_searchable' => true, 'is_used_in_spellcheck' => true]), ]; } diff --git a/src/module-elasticsuite-tracker/etc/elasticsuite_indices.xml b/src/module-elasticsuite-tracker/etc/elasticsuite_indices.xml index 3b78f6a9e..879b715fc 100644 --- a/src/module-elasticsuite-tracker/etc/elasticsuite_indices.xml +++ b/src/module-elasticsuite-tracker/etc/elasticsuite_indices.xml @@ -23,35 +23,35 @@ - + - - + + - + - - + + - - + + - - + + - + true - + true @@ -59,23 +59,23 @@ - - - - - + + + + + - + true - + true - + true @@ -85,20 +85,20 @@ - - - - - + + + + + - + - - + + @@ -110,14 +110,14 @@ - + - + - + true