Skip to content

Commit 129dedb

Browse files
author
Prabhu Ram
committed
MC-21228: Support partial word search in Elasticsearch
- query fix
1 parent 1a52ccc commit 129dedb

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,13 @@
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" />
1817
<queryReference clause="must" ref="category"/>
1918
<queryReference clause="must" ref="price"/>
2019
<queryReference clause="must" ref="visibility"/>
2120
</query>
2221
<query xsi:type="matchQuery" value="$search_term$" name="search">
2322
<match field="*"/>
2423
</query>
25-
<query xsi:type="matchQuery" value="$search_term$" name="partial_search">
26-
<match field="*"/>
27-
<match field="name" matchCondition="match_phrase_prefix"/>
28-
<match field="sku" matchCondition="match_phrase_prefix"/>
29-
</query>
3024
<query xsi:type="filteredQuery" name="category">
3125
<filterReference clause="must" ref="category_filter"/>
3226
</query>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected function buildQueries(array $matches, array $queryValue)
132132
// Checking for quoted phrase \"phrase test\", trim escaped surrounding quotes if found
133133
$count = 0;
134134
$value = preg_replace('#^"(.*)"$#m', '$1', $queryValue['value'], -1, $count);
135-
$matchCondition = ($count) ? 'match_phrase' : 'match';
135+
$condition = ($count) ? 'match_phrase' : 'match';
136136

137137
$transformedTypes = [];
138138
foreach ($matches as $match) {
@@ -153,7 +153,7 @@ protected function buildQueries(array $matches, array $queryValue)
153153
//Value is incompatible with this field type.
154154
continue;
155155
}
156-
$matchCondition = $match['matchCondition'] ?? $matchCondition;
156+
$matchCondition = $match['matchCondition'] ?? $condition;
157157
$conditions[] = [
158158
'condition' => $queryValue['condition'],
159159
'body' => [

0 commit comments

Comments
 (0)