Query String URI: Add `lenient` to the URI `q` parameters, closes #1937.
This commit is contained in:
parent
cda633afee
commit
64addee691
|
@ -85,6 +85,8 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder {
|
|||
|
||||
private String minimumShouldMatch;
|
||||
|
||||
private Boolean lenient;
|
||||
|
||||
public QueryStringQueryBuilder(String queryString) {
|
||||
this.queryString = queryString;
|
||||
}
|
||||
|
@ -279,6 +281,15 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the query string parser to be lenient when parsing field values, defaults to the index
|
||||
* setting and if not set, defaults to false.
|
||||
*/
|
||||
public QueryStringQueryBuilder lenient(Boolean lenient) {
|
||||
this.lenient = lenient;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(QueryStringQueryParser.NAME);
|
||||
|
@ -351,6 +362,9 @@ public class QueryStringQueryBuilder extends BaseQueryBuilder {
|
|||
if (quoteFieldSuffix != null) {
|
||||
builder.field("quote_field_suffix", quoteFieldSuffix);
|
||||
}
|
||||
if (lenient != null) {
|
||||
builder.field("lenient", lenient);
|
||||
}
|
||||
builder.endObject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,6 +154,7 @@ public class RestSearchAction extends BaseRestHandler {
|
|||
queryBuilder.analyzer(request.param("analyzer"));
|
||||
queryBuilder.analyzeWildcard(request.paramAsBoolean("analyze_wildcard", false));
|
||||
queryBuilder.lowercaseExpandedTerms(request.paramAsBoolean("lowercase_expanded_terms", true));
|
||||
queryBuilder.lenient(request.paramAsBooleanOptional("lenient", null));
|
||||
String defaultOperator = request.param("default_operator");
|
||||
if (defaultOperator != null) {
|
||||
if ("OR".equals(defaultOperator)) {
|
||||
|
|
Loading…
Reference in New Issue