Skip to content

Commit be34154

Browse files
committed
MC-41706: Catalog Search is not accent insensitive
- fix - modify test
1 parent 89939d3 commit be34154

File tree

2 files changed

+21
-12
lines changed
  • app/code/Magento/Elasticsearch/Model/Adapter/Index
  • dev/tests/integration/testsuite/Magento/Elasticsearch/Model/Indexer

2 files changed

+21
-12
lines changed

app/code/Magento/Elasticsearch/Model/Adapter/Index/Builder.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function build()
5858
'type' => 'custom',
5959
'tokenizer' => key($tokenizer),
6060
'filter' => array_merge(
61-
['lowercase', 'keyword_repeat'],
61+
['lowercase', 'keyword_repeat', 'asciifolding'],
6262
array_keys($filter)
6363
),
6464
'char_filter' => array_keys($charFilter)
@@ -67,26 +67,22 @@ public function build()
6767
'prefix_search' => [
6868
'type' => 'custom',
6969
'tokenizer' => key($tokenizer),
70-
'filter' => array_merge(
71-
['lowercase', 'keyword_repeat']
72-
),
70+
'filter' => ['lowercase', 'keyword_repeat', 'asciifolding'],
7371
'char_filter' => array_keys($charFilter)
7472
],
7573
'sku' => [
7674
'type' => 'custom',
7775
'tokenizer' => 'keyword',
7876
'filter' => array_merge(
79-
['lowercase', 'keyword_repeat'],
77+
['lowercase', 'keyword_repeat', 'asciifolding'],
8078
array_keys($filter)
8179
),
8280
],
8381
// this analyzer must not include stemmer filter
8482
'sku_prefix_search' => [
8583
'type' => 'custom',
8684
'tokenizer' => 'keyword',
87-
'filter' => array_merge(
88-
['lowercase', 'keyword_repeat']
89-
),
85+
'filter' => ['lowercase', 'keyword_repeat', 'asciifolding']
9086
]
9187
],
9288
'tokenizer' => $tokenizer,

dev/tests/integration/testsuite/Magento/Elasticsearch/Model/Indexer/ReindexAllTest.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,30 @@ public function testSortCaseSensitive(): void
174174
*
175175
* @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix indexerhandlertest_configurable
176176
* @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_products.php
177+
* @magentoDataFixture Magento/Catalog/_files/products.php
178+
* @dataProvider searchSpecificProductDataProvider
179+
* @param string $searchName
180+
* @param string $sku
181+
* @param int $expectedCount
177182
*/
178-
public function testSearchSpecificProduct()
183+
public function testSearchSpecificProduct(string $searchName, string $sku, int $expectedCount)
179184
{
180185
$this->reindexAll();
181-
$result = $this->searchByName('12345');
182-
self::assertCount(1, $result);
186+
$result = $this->searchByName($searchName);
187+
self::assertCount($expectedCount, $result);
183188

184-
$specificProduct = $this->productRepository->get('configurable_12345');
189+
$specificProduct = $this->productRepository->get($sku);
185190
self::assertEquals($specificProduct->getId(), $result[0]['_id']);
186191
}
187192

193+
public function searchSpecificProductDataProvider(): array
194+
{
195+
return [
196+
'search by numeric name' => ['12345', 'configurable_12345', 1],
197+
'search by name with diacritics' => ['Cùstöm Dèsign', 'custom-design-simple-product', 1],
198+
];
199+
}
200+
188201
/**
189202
* @param string $text
190203
* @return array

0 commit comments

Comments
 (0)