Java api: restore support for minimumShouldMatch and disableCoord in TermsQueryBuilder
TermsQueryParser still parses those values although deprecated. These need to be present in the java api as well to get ready for the query refactoring, where the builders are the intermediate query format that we parse our json queries into. Whatever the parser supports need to be supported by the builder as well. Closes #12870
This commit is contained in:
parent
2e0b548b06
commit
4010e7e9a7
|
@ -32,6 +32,10 @@ public class TermsQueryBuilder extends QueryBuilder implements BoostableQueryBui
|
||||||
|
|
||||||
private final Object values;
|
private final Object values;
|
||||||
|
|
||||||
|
private String minimumShouldMatch;
|
||||||
|
|
||||||
|
private Boolean disableCoord;
|
||||||
|
|
||||||
private String queryName;
|
private String queryName;
|
||||||
|
|
||||||
private String execution;
|
private String execution;
|
||||||
|
@ -125,6 +129,26 @@ public class TermsQueryBuilder extends QueryBuilder implements BoostableQueryBui
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the minimum number of matches across the provided terms. Defaults to <tt>1</tt>.
|
||||||
|
* @deprecated use [bool] query instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public TermsQueryBuilder minimumShouldMatch(String minimumShouldMatch) {
|
||||||
|
this.minimumShouldMatch = minimumShouldMatch;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables <tt>Similarity#coord(int,int)</tt> in scoring. Defaults to <tt>false</tt>.
|
||||||
|
* @deprecated use [bool] query instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public TermsQueryBuilder disableCoord(boolean disableCoord) {
|
||||||
|
this.disableCoord = disableCoord;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the filter name for the filter that can be used when searching for matched_filters per hit.
|
* Sets the filter name for the filter that can be used when searching for matched_filters per hit.
|
||||||
*/
|
*/
|
||||||
|
@ -148,6 +172,14 @@ public class TermsQueryBuilder extends QueryBuilder implements BoostableQueryBui
|
||||||
builder.field("execution", execution);
|
builder.field("execution", execution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (minimumShouldMatch != null) {
|
||||||
|
builder.field("minimum_should_match", minimumShouldMatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disableCoord != null) {
|
||||||
|
builder.field("disable_coord", disableCoord);
|
||||||
|
}
|
||||||
|
|
||||||
if (boost != -1) {
|
if (boost != -1) {
|
||||||
builder.field("boost", boost);
|
builder.field("boost", boost);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class TermsQueryParser implements QueryParser {
|
||||||
|
|
||||||
public static final String NAME = "terms";
|
public static final String NAME = "terms";
|
||||||
private static final ParseField MIN_SHOULD_MATCH_FIELD = new ParseField("min_match", "min_should_match").withAllDeprecated("Use [bool] query instead");
|
private static final ParseField MIN_SHOULD_MATCH_FIELD = new ParseField("min_match", "min_should_match").withAllDeprecated("Use [bool] query instead");
|
||||||
|
private static final ParseField DISABLE_COORD_FIELD = new ParseField("disable_coord").withAllDeprecated("Use [bool] query instead");
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -149,7 +150,7 @@ public class TermsQueryParser implements QueryParser {
|
||||||
minShouldMatch = parser.textOrNull();
|
minShouldMatch = parser.textOrNull();
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = parser.floatValue();
|
boost = parser.floatValue();
|
||||||
} else if (("disable_coord").equals(currentFieldName) || ("disableCoord").equals(currentFieldName)) {
|
} else if (parseContext.parseFieldMatcher().match(currentFieldName, DISABLE_COORD_FIELD)) {
|
||||||
disableCoord = parser.booleanValue();
|
disableCoord = parser.booleanValue();
|
||||||
} else if ("_name".equals(currentFieldName)) {
|
} else if ("_name".equals(currentFieldName)) {
|
||||||
queryName = parser.text();
|
queryName = parser.text();
|
||||||
|
|
Loading…
Reference in New Issue