Unverified Commit 61a7028f authored by AMIT KUMAR's avatar AMIT KUMAR Committed by GitHub
Browse files

Issue #SB-29813 feat:fixed fuzzy issue (#1082)

* Issue #SB-29813 feat:fixed fuzzy issue

* Issue #SB-29813 feat:fixed fuzzy issue
Showing with 7 additions and 11 deletions
+7 -11
......@@ -22,7 +22,6 @@ import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.ExistsQueryBuilder;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.RangeQueryBuilder;
......@@ -449,10 +448,9 @@ public class ElasticSearchHelper {
* @param value of the attribute
* @return MatchQueryBuilder
*/
public static MatchQueryBuilder createFuzzyMatchQuery(String name, Object value) {
return QueryBuilders.matchQuery(name, value)
.fuzziness(Fuzziness.AUTO)
.fuzzyTranspositions(true);
public static void createFuzzyMatchQuery(BoolQueryBuilder query, String name, Object value) {
query.must(
QueryBuilders.matchQuery(name, value).fuzziness(Fuzziness.AUTO).fuzzyTranspositions(true));
}
/**
......
......@@ -427,16 +427,14 @@ public class ElasticSearchRestHighImpl implements ElasticSearchService {
}
}
// set final query to search request builder
searchSourceBuilder.query(query);
// do fuzzy search
if (MapUtils.isNotEmpty(searchDTO.getFuzzy())) {
Map.Entry<String, String> entry = searchDTO.getFuzzy().entrySet().iterator().next();
MatchQueryBuilder queryBuilder =
ElasticSearchHelper.createFuzzyMatchQuery(entry.getKey(), entry.getValue());
searchSourceBuilder.query(queryBuilder);
ElasticSearchHelper.createFuzzyMatchQuery(query, entry.getKey(), entry.getValue());
}
// set final query to search request builder
searchSourceBuilder.query(query);
List finalFacetList = new ArrayList();
if (null != searchDTO.getFacets() && !searchDTO.getFacets().isEmpty()) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment