Skip to content

Commit

Permalink
Query DSL: deprecate locale parameters in query_string and simple_que…
Browse files Browse the repository at this point in the history
…ry_string

The configured analysis chain should be used instead.

Relates to elastic#13229
  • Loading branch information
javanna committed Oct 5, 2015
1 parent 24f6809 commit 3d05327
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,18 @@ public void useDisMax(boolean useDisMax) {
this.useDisMax = useDisMax;
}

/**
* @deprecated properly configure the analysis chain instead
*/
@Deprecated
public void locale(Locale locale) {
this.locale = locale;
}

/**
* @deprecated properly configure the analysis chain instead
*/
@Deprecated
public Locale locale() {
return this.locale;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ public QueryStringQueryBuilder queryName(String queryName) {
return this;
}

/**
* @deprecated properly configure the analysis chain instead
*/
@Deprecated
public QueryStringQueryBuilder locale(Locale locale) {
this.locale = locale;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class QueryStringQueryParser implements QueryParser {

public static final String NAME = "query_string";
private static final ParseField FUZZINESS = Fuzziness.FIELD.withDeprecation("fuzzy_min_sim");
private static final ParseField LOCALE_FIELD = new ParseField("locale").withAllDeprecated("properly configure the analysis chain instead");

private final boolean defaultAnalyzeWildcard;
private final boolean defaultAllowLeadingWildcard;
Expand Down Expand Up @@ -193,7 +194,7 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
qpSettings.quoteFieldSuffix(parser.textOrNull());
} else if ("lenient".equalsIgnoreCase(currentFieldName)) {
qpSettings.lenient(parser.booleanValue());
} else if ("locale".equals(currentFieldName)) {
} else if (parseContext.parseFieldMatcher().match(currentFieldName, LOCALE_FIELD)) {
String localeStr = parser.text();
qpSettings.locale(LocaleUtils.parse(localeStr));
} else if ("time_zone".equals(currentFieldName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.index.query;

import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.XContentBuilder;

import java.io.IOException;
Expand Down Expand Up @@ -134,11 +133,19 @@ public SimpleQueryStringBuilder lowercaseExpandedTerms(boolean lowercaseExpanded
return this;
}

/**
* @deprecated properly configure the analysis chain instead
*/
@Deprecated
public SimpleQueryStringBuilder locale(Locale locale) {
this.locale = locale;
return this;
}

/**
* @deprecated properly configure the analysis chain instead
*/
@Deprecated
public SimpleQueryStringBuilder lenient(boolean lenient) {
this.lenient = lenient;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.lucene.search.Queries;
Expand Down Expand Up @@ -72,6 +73,8 @@ public class SimpleQueryStringParser implements QueryParser {

public static final String NAME = "simple_query_string";

private static final ParseField LOCALE_FIELD = new ParseField("locale").withAllDeprecated("properly configure the analysis chain instead");

@Inject
public SimpleQueryStringParser() {

Expand Down Expand Up @@ -170,7 +173,7 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
flags = SimpleQueryStringFlag.ALL.value();
}
}
} else if ("locale".equals(currentFieldName)) {
} else if (parseContext.parseFieldMatcher().match(currentFieldName, LOCALE_FIELD)) {
String localeStr = parser.text();
Locale locale = LocaleUtils.parse(localeStr);
sqsSettings.locale(locale);
Expand Down

0 comments on commit 3d05327

Please sign in to comment.