Remove deprecated methods from QueryStringQueryBuilder (#35912)

This change removes the deprecated useDisMax() and useAllFields() methods from
the QueryStringQueryBuilder and related tests. The disMax parameter has already
been a no-op since 6.0 and also the useAllFields has been deprecated since 6.0
and there is a direct replacement via defaultField.
This commit is contained in:
Christoph Büscher 2018-11-28 11:09:03 +01:00 committed by GitHub
parent d948edfd69
commit 2f547bac65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 45 deletions

View File

@ -250,22 +250,6 @@ public class QueryStringQueryBuilder extends AbstractQueryBuilder<QueryStringQue
return this.defaultField;
}
/**
* This setting is deprecated, set {@link #defaultField(String)} to "*" instead.
*/
@Deprecated
public QueryStringQueryBuilder useAllFields(Boolean useAllFields) {
if (useAllFields != null && useAllFields) {
this.defaultField = "*";
}
return this;
}
@Deprecated
public Boolean useAllFields() {
return defaultField == null ? null : Regex.isMatchAllPattern(defaultField);
}
/**
* Adds a field to run the query string against. The field will be associated with the
* default boost of {@link AbstractQueryBuilder#DEFAULT_BOOST}.
@ -305,22 +289,6 @@ public class QueryStringQueryBuilder extends AbstractQueryBuilder<QueryStringQue
return this;
}
/**
* Use {@link QueryStringQueryBuilder#tieBreaker} instead.
*/
@Deprecated
public QueryStringQueryBuilder useDisMax(boolean useDisMax) {
return this;
}
/**
* Use {@link QueryStringQueryBuilder#tieBreaker} instead.
*/
@Deprecated
public boolean useDisMax() {
return true;
}
/**
* When more than one field is used with the query string, and combined queries are using
* dis max, control the tie breaker for it.

View File

@ -157,9 +157,6 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
if (randomBoolean()) {
queryStringQueryBuilder.minimumShouldMatch(randomMinimumShouldMatch());
}
if (randomBoolean()) {
queryStringQueryBuilder.useDisMax(randomBoolean());
}
if (randomBoolean()) {
queryStringQueryBuilder.timeZone(randomDateTimeZone().getID());
}

View File

@ -250,10 +250,9 @@ public class QueryStringIT extends ESIntegTestCase {
}
public void testBooleanStrictQuery() throws Exception {
Exception e = expectThrows(Exception.class, () ->
client().prepareSearch("test").setQuery(
queryStringQuery("foo").field("f_bool")).get());
assertThat(ExceptionsHelper.detailedMessage(e),
Exception e = expectThrows(Exception.class,
() -> client().prepareSearch("test").setQuery(queryStringQuery("foo").field("f_bool")).get());
assertThat(ExceptionsHelper.unwrap(e, IllegalArgumentException.class).getMessage(),
containsString("Can't parse boolean value [foo], expected [true] or [false]"));
}
@ -261,8 +260,7 @@ public class QueryStringIT extends ESIntegTestCase {
Exception e = expectThrows(Exception.class, () ->
client().prepareSearch("test").setQuery(
queryStringQuery("f_date:[now-2D TO now]").lenient(false)).get());
assertThat(ExceptionsHelper.detailedMessage(e),
containsString("unit [D] not supported for date math [-2D]"));
assertThat(e.getCause().getMessage(), containsString("unit [D] not supported for date math [-2D]"));
}
public void testLimitOnExpandedFields() throws Exception {
@ -288,11 +286,11 @@ public class QueryStringIT extends ESIntegTestCase {
Exception e = expectThrows(Exception.class, () -> {
QueryStringQueryBuilder qb = queryStringQuery("bar");
if (randomBoolean()) {
qb.useAllFields(true);
qb.defaultField("*");
}
client().prepareSearch("toomanyfields").setQuery(qb).get();
});
assertThat(ExceptionsHelper.detailedMessage(e),
assertThat(ExceptionsHelper.unwrap(e, IllegalArgumentException.class).getMessage(),
containsString("field expansion matches too many fields, limit: " + CLUSTER_MAX_CLAUSE_COUNT + ", got: "
+ (CLUSTER_MAX_CLAUSE_COUNT + 1)));
}

View File

@ -37,7 +37,6 @@ public class QueryStringQuery extends LeafQuery {
appliers.put("lowercase_expanded_terms", (qb, s) -> {});
appliers.put("enable_position_increments", (qb, s) -> qb.enablePositionIncrements(Booleans.parseBoolean(s)));
appliers.put("escape", (qb, s) -> qb.escape(Booleans.parseBoolean(s)));
appliers.put("use_dis_max", (qb, s) -> qb.useDisMax(Booleans.parseBoolean(s)));
appliers.put("fuzzy_prefix_length", (qb, s) -> qb.fuzzyPrefixLength(Integer.valueOf(s)));
appliers.put("fuzzy_max_expansions", (qb, s) -> qb.fuzzyMaxExpansions(Integer.valueOf(s)));
appliers.put("fuzzy_rewrite", (qb, s) -> qb.fuzzyRewrite(s));
@ -50,7 +49,6 @@ public class QueryStringQuery extends LeafQuery {
appliers.put("lenient", (qb, s) -> qb.lenient(Booleans.parseBoolean(s)));
appliers.put("locale", (qb, s) -> {});
appliers.put("time_zone", (qb, s) -> qb.timeZone(s));
appliers.put("all_fields", (qb, s) -> qb.useAllFields(Booleans.parseBoolean(s)));
appliers.put("type", (qb, s) -> qb.type(MultiMatchQueryBuilder.Type.parse(s, LoggingDeprecationHandler.INSTANCE)));
appliers.put("auto_generate_synonyms_phrase_query", (qb, s) -> qb.autoGenerateSynonymsPhraseQuery(Booleans.parseBoolean(s)));
appliers.put("fuzzy_transpositions", (qb, s) -> qb.fuzzyTranspositions(Booleans.parseBoolean(s)));