From 37992ac4d4518dc7f318b7391bf91c4759042f58 Mon Sep 17 00:00:00 2001 From: MaxKsyunz Date: Wed, 15 Jun 2022 17:40:29 -0700 Subject: [PATCH] Add analyzer and operator parameters to match_bool_prefix in sql and ppl Signed-off-by: MaxKsyunz --- .../script/filter/lucene/relevance/MatchBoolPrefixQuery.java | 3 +++ .../script/filter/lucene/MatchBoolPrefixQueryTest.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/MatchBoolPrefixQuery.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/MatchBoolPrefixQuery.java index e686f50082..754a09259d 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/MatchBoolPrefixQuery.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/MatchBoolPrefixQuery.java @@ -7,6 +7,7 @@ import com.google.common.collect.ImmutableMap; import org.opensearch.index.query.MatchBoolPrefixQueryBuilder; +import org.opensearch.index.query.Operator; import org.opensearch.index.query.QueryBuilders; /** @@ -28,6 +29,8 @@ public MatchBoolPrefixQuery() { (b, v) -> b.fuzzyTranspositions(Boolean.parseBoolean(v.stringValue()))) .put("fuzzy_rewrite", (b, v) -> b.fuzzyRewrite(v.stringValue())) .put("boost", (b, v) -> b.boost(Float.parseFloat(v.stringValue()))) + .put("analyzer", (b, v) -> b.analyzer(v.stringValue())) + .put("operator", (b,v) -> b.operator(Operator.fromString(v.stringValue()))) .build()); } diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/MatchBoolPrefixQueryTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/MatchBoolPrefixQueryTest.java index dda1a201be..00cf3158c4 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/MatchBoolPrefixQueryTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/MatchBoolPrefixQueryTest.java @@ -45,7 +45,10 @@ static Stream> generateValidData() { dsl.namedArgument("fuzzy_transpositions", DSL.literal("true")), dsl.namedArgument("fuzzy_rewrite", DSL.literal("constant_score")), dsl.namedArgument("minimum_should_match", DSL.literal("3")), - dsl.namedArgument("boost", DSL.literal("1")) + dsl.namedArgument("boost", DSL.literal("1")), + dsl.namedArgument("analyzer", DSL.literal("simple")), + dsl.namedArgument("operator", DSL.literal("Or")), + dsl.namedArgument("operator", DSL.literal("and")) ).stream().map(arg -> List.of(field, query, arg)); }