Skip to content

Commit

Permalink
Query String URI: Add lenient to the URI q parameters, closes #1937.
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed May 10, 2012
1 parent cda633a commit 64addee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Expand Up @@ -85,6 +85,8 @@ public static enum Operator {

private String minimumShouldMatch;

private Boolean lenient;

public QueryStringQueryBuilder(String queryString) {
this.queryString = queryString;
}
Expand Down Expand Up @@ -279,6 +281,15 @@ public QueryStringQueryBuilder quoteFieldSuffix(String quoteFieldSuffix) {
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);
Expand Down Expand Up @@ -351,6 +362,9 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
if (quoteFieldSuffix != null) {
builder.field("quote_field_suffix", quoteFieldSuffix);
}
if (lenient != null) {
builder.field("lenient", lenient);
}
builder.endObject();
}
}
Expand Up @@ -154,6 +154,7 @@ private SearchSourceBuilder parseSearchSource(RestRequest request) {
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)) {
Expand Down

0 comments on commit 64addee

Please sign in to comment.