From 37992ac4d4518dc7f318b7391bf91c4759042f58 Mon Sep 17 00:00:00 2001 From: MaxKsyunz Date: Wed, 15 Jun 2022 17:40:29 -0700 Subject: [PATCH 1/2] 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)); } From 111a8e6eeba51d46cc68250e468af009a4b111ca Mon Sep 17 00:00:00 2001 From: MaxKsyunz Date: Thu, 16 Jun 2022 19:08:21 -0700 Subject: [PATCH 2/2] Update SQL and PPL documentation. Mention analyzer and operator optional parameters. Signed-off-by: MaxKsyunz --- docs/user/dql/functions.rst | 2 ++ docs/user/ppl/functions/relevance.rst | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/user/dql/functions.rst b/docs/user/dql/functions.rst index cb6c32ea4d..c0e3fa6b44 100644 --- a/docs/user/dql/functions.rst +++ b/docs/user/dql/functions.rst @@ -2253,6 +2253,8 @@ The match_bool_prefix function maps to the match_bool_prefix query in the search - fuzzy_rewrite - minimum_should_match - boost +- operator +- analyzer Example with only ``field`` and ``query`` expressions, and all other parameters are set default values:: diff --git a/docs/user/ppl/functions/relevance.rst b/docs/user/ppl/functions/relevance.rst index 604666e0d8..a198d7c8af 100644 --- a/docs/user/ppl/functions/relevance.rst +++ b/docs/user/ppl/functions/relevance.rst @@ -117,6 +117,7 @@ The match_bool_prefix function maps to the match_bool_prefix query in the search - max_expansions - prefix_length - fuzzy_transpositions +- operator - fuzzy_rewrite - minimum_should_match - boost