Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add analyzer and operator parameters to match_bool_prefix #72

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"))
acarbonetto marked this conversation as resolved.
Show resolved Hide resolved
).stream().map(arg -> List.of(field, query, arg));
}

Expand Down