Java api: add missing support for escape to QueryStringQueryBuilder
QueryStringQueryParser parses `escape`, but java api users had no chance to actually set it. Closes #13016
This commit is contained in:
parent
650a86e2ce
commit
ded442952b
|
@ -68,7 +68,6 @@ public class QueryStringQueryBuilder extends QueryBuilder implements BoostableQu
|
||||||
|
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
|
|
||||||
|
|
||||||
private float boost = -1;
|
private float boost = -1;
|
||||||
|
|
||||||
private Fuzziness fuzziness;
|
private Fuzziness fuzziness;
|
||||||
|
@ -99,6 +98,8 @@ public class QueryStringQueryBuilder extends QueryBuilder implements BoostableQu
|
||||||
/** To limit effort spent determinizing regexp queries. */
|
/** To limit effort spent determinizing regexp queries. */
|
||||||
private Integer maxDeterminizedStates;
|
private Integer maxDeterminizedStates;
|
||||||
|
|
||||||
|
private Boolean escape;
|
||||||
|
|
||||||
public QueryStringQueryBuilder(String queryString) {
|
public QueryStringQueryBuilder(String queryString) {
|
||||||
this.queryString = queryString;
|
this.queryString = queryString;
|
||||||
}
|
}
|
||||||
|
@ -159,11 +160,11 @@ public class QueryStringQueryBuilder extends QueryBuilder implements BoostableQu
|
||||||
/**
|
/**
|
||||||
* Sets the boolean operator of the query parser used to parse the query string.
|
* Sets the boolean operator of the query parser used to parse the query string.
|
||||||
* <p/>
|
* <p/>
|
||||||
* <p>In default mode ({@link FieldQueryBuilder.Operator#OR}) terms without any modifiers
|
* <p>In default mode ({@link Operator#OR}) terms without any modifiers
|
||||||
* are considered optional: for example <code>capital of Hungary</code> is equal to
|
* are considered optional: for example <code>capital of Hungary</code> is equal to
|
||||||
* <code>capital OR of OR Hungary</code>.
|
* <code>capital OR of OR Hungary</code>.
|
||||||
* <p/>
|
* <p/>
|
||||||
* <p>In {@link FieldQueryBuilder.Operator#AND} mode terms are considered to be in conjunction: the
|
* <p>In {@link Operator#AND} mode terms are considered to be in conjunction: the
|
||||||
* above mentioned query is parsed as <code>capital AND of AND Hungary</code>
|
* above mentioned query is parsed as <code>capital AND of AND Hungary</code>
|
||||||
*/
|
*/
|
||||||
public QueryStringQueryBuilder defaultOperator(Operator defaultOperator) {
|
public QueryStringQueryBuilder defaultOperator(Operator defaultOperator) {
|
||||||
|
@ -342,6 +343,14 @@ public class QueryStringQueryBuilder extends QueryBuilder implements BoostableQu
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to <tt>true</tt> to enable escaping of the query string
|
||||||
|
*/
|
||||||
|
public QueryStringQueryBuilder escape(boolean escape) {
|
||||||
|
this.escape = escape;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(QueryStringQueryParser.NAME);
|
builder.startObject(QueryStringQueryParser.NAME);
|
||||||
|
@ -431,6 +440,9 @@ public class QueryStringQueryBuilder extends QueryBuilder implements BoostableQu
|
||||||
if (timeZone != null) {
|
if (timeZone != null) {
|
||||||
builder.field("time_zone", timeZone);
|
builder.field("time_zone", timeZone);
|
||||||
}
|
}
|
||||||
|
if (escape != null) {
|
||||||
|
builder.field("escape", escape);
|
||||||
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue