Skip to content

Commit d29fe2f

Browse files
author
Prabhu Ram
committed
MC-21228: Support partial word search in Elasticsearch
- Fixed integration failures
1 parent 07d75d2 commit d29fe2f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

app/code/Magento/CatalogSearch/etc/search_request.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414
<queries>
1515
<query xsi:type="boolQuery" name="quick_search_container" boost="1">
1616
<queryReference clause="should" ref="search" />
17+
<queryReference clause="should" ref="partial_search" />
1718
<queryReference clause="must" ref="category"/>
1819
<queryReference clause="must" ref="price"/>
1920
<queryReference clause="must" ref="visibility"/>
2021
</query>
2122
<query xsi:type="matchQuery" value="$search_term$" name="search">
2223
<match field="*"/>
24+
</query>
25+
<query xsi:type="matchQuery" value="$search_term$" name="partial_search">
26+
<match field="*"/>
2327
<match field="name" matchCondition="match_phrase_prefix"/>
2428
<match field="sku" matchCondition="match_phrase_prefix"/>
2529
</query>

app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function build(array $selectQuery, RequestQueryInterface $requestQuery, $
8383
$matchKey = array_keys($queryBody)[0];
8484
foreach ($queryBody[$matchKey] as $field => $matchQuery) {
8585
$matchQuery['boost'] = $requestQueryBoost + $matchQuery['boost'];
86-
if ($minimumShouldMatch) {
86+
if ($minimumShouldMatch && $matchKey != 'match_phrase_prefix') {
8787
$matchQuery['minimum_should_match'] = $minimumShouldMatch;
8888
}
8989
$queryBody[$matchKey][$field] = $matchQuery;

0 commit comments

Comments
 (0)