Skip to content

Commit

Permalink
Merge pull request #72 from Bit-Quill/dev-match_bool_prefix-#187-more…
Browse files Browse the repository at this point in the history
…-params

Add analyzer and operator parameters to match_bool_prefix
  • Loading branch information
MaxKsyunz authored Jun 17, 2022
2 parents 0bcc123 + 111a8e6 commit 2d2ddf8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/user/dql/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down
1 change: 1 addition & 0 deletions docs/user/ppl/functions/relevance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ static Stream<List<Expression>> 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));
}

Expand Down

0 comments on commit 2d2ddf8

Please sign in to comment.