Skip to content

Commit c93c7f3

Browse files
authored
Remove deprecated options for query_string (#29203)
This commit removes some parameters deprecated in 6.x (or 5.x): `use_dismax`, `split_on_whitespace`, `all_fields` and `lowercase_expanded_terms`. Closes #25551
1 parent 24c8d8f commit c93c7f3

File tree

3 files changed

+13
-55
lines changed

3 files changed

+13
-55
lines changed

docs/reference/migration/migrate_7_0/search.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
* The default value for `transpositions` parameter of `fuzzy` query
66
has been changed to `true`.
77

8+
* The `query_string` options `use_dismax`, `split_on_whitespace`,
9+
`all_fields`, `locale`, `auto_generate_phrase_query` and
10+
`lowercase_expanded_terms` deprecated in 6.x have been removed.
11+
812
==== Adaptive replica selection enabled by default
913

1014
Adaptive replica selection has been enabled by default. If you wish to return to

docs/reference/query-dsl/query-string-query.asciidoc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ phrase matches are required. Default value is `0`.
9999

100100
|`boost` |Sets the boost value of the query. Defaults to `1.0`.
101101

102-
|`auto_generate_phrase_queries` |Defaults to `false`.
103-
104102
|`analyze_wildcard` |By default, wildcards terms in a query string are
105103
not analyzed. By setting this value to `true`, a best effort will be
106104
made to analyze those as well.
@@ -129,10 +127,6 @@ comprehensive example.
129127
|`auto_generate_synonyms_phrase_query` |Whether phrase queries should be automatically generated for multi terms synonyms.
130128
Defaults to `true`.
131129

132-
|`all_fields` | deprecated[6.0.0, set `default_field` to `*` instead]
133-
Perform the query on all fields detected in the mapping that can
134-
be queried.
135-
136130
|=======================================================================
137131

138132
When a multi term query is being generated, one can control how it gets

server/src/main/java/org/elasticsearch/index/query/QueryStringQueryBuilder.java

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,9 @@ public class QueryStringQueryBuilder extends AbstractQueryBuilder<QueryStringQue
7878
private static final ParseField ANALYZER_FIELD = new ParseField("analyzer");
7979
private static final ParseField QUOTE_ANALYZER_FIELD = new ParseField("quote_analyzer");
8080
private static final ParseField ALLOW_LEADING_WILDCARD_FIELD = new ParseField("allow_leading_wildcard");
81-
private static final ParseField AUTO_GENERATE_PHRASE_QUERIES_FIELD = new ParseField("auto_generate_phrase_queries")
82-
.withAllDeprecated("This setting is ignored, use [type=phrase] instead");
8381
private static final ParseField MAX_DETERMINIZED_STATES_FIELD = new ParseField("max_determinized_states");
84-
private static final ParseField LOWERCASE_EXPANDED_TERMS_FIELD = new ParseField("lowercase_expanded_terms")
85-
.withAllDeprecated("Decision is now made by the analyzer");
8682
private static final ParseField ENABLE_POSITION_INCREMENTS_FIELD = new ParseField("enable_position_increments");
8783
private static final ParseField ESCAPE_FIELD = new ParseField("escape");
88-
private static final ParseField USE_DIS_MAX_FIELD = new ParseField("use_dis_max")
89-
.withAllDeprecated("Set [tie_breaker] to 1 instead");
9084
private static final ParseField FUZZY_PREFIX_LENGTH_FIELD = new ParseField("fuzzy_prefix_length");
9185
private static final ParseField FUZZY_MAX_EXPANSIONS_FIELD = new ParseField("fuzzy_max_expansions");
9286
private static final ParseField FUZZY_REWRITE_FIELD = new ParseField("fuzzy_rewrite");
@@ -97,13 +91,7 @@ public class QueryStringQueryBuilder extends AbstractQueryBuilder<QueryStringQue
9791
private static final ParseField MINIMUM_SHOULD_MATCH_FIELD = new ParseField("minimum_should_match");
9892
private static final ParseField QUOTE_FIELD_SUFFIX_FIELD = new ParseField("quote_field_suffix");
9993
private static final ParseField LENIENT_FIELD = new ParseField("lenient");
100-
private static final ParseField LOCALE_FIELD = new ParseField("locale")
101-
.withAllDeprecated("Decision is now made by the analyzer");
10294
private static final ParseField TIME_ZONE_FIELD = new ParseField("time_zone");
103-
private static final ParseField SPLIT_ON_WHITESPACE = new ParseField("split_on_whitespace")
104-
.withAllDeprecated("This setting is ignored, the parser always splits on operator");
105-
private static final ParseField ALL_FIELDS_FIELD = new ParseField("all_fields")
106-
.withAllDeprecated("Set [default_field] to `*` instead");
10795
private static final ParseField TYPE_FIELD = new ParseField("type");
10896
private static final ParseField GENERATE_SYNONYMS_PHRASE_QUERY = new ParseField("auto_generate_synonyms_phrase_query");
10997
private static final ParseField FUZZY_TRANSPOSITIONS_FIELD = new ParseField("fuzzy_transpositions");
@@ -193,13 +181,7 @@ public QueryStringQueryBuilder(StreamInput in) throws IOException {
193181
}
194182
allowLeadingWildcard = in.readOptionalBoolean();
195183
analyzeWildcard = in.readOptionalBoolean();
196-
if (in.getVersion().before(Version.V_5_1_1)) {
197-
in.readBoolean(); // lowercase_expanded_terms
198-
}
199184
enablePositionIncrements = in.readBoolean();
200-
if (in.getVersion().before(Version.V_5_1_1)) {
201-
in.readString(); // locale
202-
}
203185
fuzziness = new Fuzziness(in);
204186
fuzzyPrefixLength = in.readVInt();
205187
fuzzyMaxExpansions = in.readVInt();
@@ -219,13 +201,11 @@ public QueryStringQueryBuilder(StreamInput in) throws IOException {
219201
timeZone = in.readOptionalTimeZone();
220202
escape = in.readBoolean();
221203
maxDeterminizedStates = in.readVInt();
222-
if (in.getVersion().onOrAfter(Version.V_5_1_1)) {
223-
if (in.getVersion().before(Version.V_6_0_0_beta1)) {
224-
in.readBoolean(); // split_on_whitespace
225-
Boolean useAllField = in.readOptionalBoolean();
226-
if (useAllField != null && useAllField) {
227-
defaultField = "*";
228-
}
204+
if (in.getVersion().onOrAfter(Version.V_5_1_1) && in.getVersion().before(Version.V_6_0_0_beta1)) {
205+
in.readBoolean(); // split_on_whitespace
206+
Boolean useAllField = in.readOptionalBoolean();
207+
if (useAllField != null && useAllField) {
208+
defaultField = "*";
229209
}
230210
}
231211
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
@@ -252,13 +232,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
252232
}
253233
out.writeOptionalBoolean(this.allowLeadingWildcard);
254234
out.writeOptionalBoolean(this.analyzeWildcard);
255-
if (out.getVersion().before(Version.V_5_1_1)) {
256-
out.writeBoolean(true); // lowercase_expanded_terms
257-
}
258235
out.writeBoolean(this.enablePositionIncrements);
259-
if (out.getVersion().before(Version.V_5_1_1)) {
260-
out.writeString(Locale.ROOT.toLanguageTag()); // locale
261-
}
262236
this.fuzziness.writeTo(out);
263237
out.writeVInt(this.fuzzyPrefixLength);
264238
out.writeVInt(this.fuzzyMaxExpansions);
@@ -277,12 +251,10 @@ protected void doWriteTo(StreamOutput out) throws IOException {
277251
out.writeOptionalTimeZone(timeZone);
278252
out.writeBoolean(this.escape);
279253
out.writeVInt(this.maxDeterminizedStates);
280-
if (out.getVersion().onOrAfter(Version.V_5_1_1)) {
281-
if (out.getVersion().before(Version.V_6_0_0_beta1)) {
282-
out.writeBoolean(false); // split_on_whitespace
283-
Boolean useAllFields = defaultField == null ? null : Regex.isMatchAllPattern(defaultField);
284-
out.writeOptionalBoolean(useAllFields);
285-
}
254+
if (out.getVersion().onOrAfter(Version.V_5_1_1) && out.getVersion().before(Version.V_6_0_0_beta1)) {
255+
out.writeBoolean(false); // split_on_whitespace
256+
Boolean useAllFields = defaultField == null ? null : Regex.isMatchAllPattern(defaultField);
257+
out.writeOptionalBoolean(useAllFields);
286258
}
287259
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
288260
out.writeBoolean(autoGenerateSynonymsPhraseQuery);
@@ -824,8 +796,6 @@ public static QueryStringQueryBuilder fromXContent(XContentParser parser) throws
824796
quoteFieldSuffix = parser.textOrNull();
825797
} else if (LENIENT_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
826798
lenient = parser.booleanValue();
827-
} else if (ALL_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
828-
defaultField = "*";
829799
} else if (MAX_DETERMINIZED_STATES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
830800
maxDeterminizedStates = parser.intValue();
831801
} else if (TIME_ZONE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
@@ -841,16 +811,6 @@ public static QueryStringQueryBuilder fromXContent(XContentParser parser) throws
841811
autoGenerateSynonymsPhraseQuery = parser.booleanValue();
842812
} else if (FUZZY_TRANSPOSITIONS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
843813
fuzzyTranspositions = parser.booleanValue();
844-
} else if (AUTO_GENERATE_PHRASE_QUERIES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
845-
// ignore, deprecated setting
846-
} else if (LOWERCASE_EXPANDED_TERMS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
847-
// ignore, deprecated setting
848-
} else if (LOCALE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
849-
// ignore, deprecated setting
850-
} else if (USE_DIS_MAX_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
851-
// ignore, deprecated setting
852-
} else if (SPLIT_ON_WHITESPACE.match(currentFieldName, parser.getDeprecationHandler())) {
853-
// ignore, deprecated setting
854814
} else {
855815
throw new ParsingException(parser.getTokenLocation(), "[" + QueryStringQueryBuilder.NAME +
856816
"] query does not support [" + currentFieldName + "]");

0 commit comments

Comments
 (0)