2010-02-08 15:30:06 +02:00
|
|
|
/*
|
2011-12-06 02:42:25 +02:00
|
|
|
* Licensed to ElasticSearch and Shay Banon under one
|
2010-02-08 15:30:06 +02:00
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
2011-12-06 02:42:25 +02:00
|
|
|
* regarding copyright ownership. ElasticSearch licenses this
|
2010-02-08 15:30:06 +02:00
|
|
|
* file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
2011-06-03 04:32:27 +03:00
|
|
|
package org.elasticsearch.index.query;
|
2010-02-08 15:30:06 +02:00
|
|
|
|
2011-12-06 02:42:25 +02:00
|
|
|
import gnu.trove.impl.Constants;
|
|
|
|
import gnu.trove.map.hash.TObjectFloatHashMap;
|
2010-09-12 23:20:13 +02:00
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
2010-02-08 15:30:06 +02:00
|
|
|
|
|
|
|
import java.io.IOException;
|
2010-03-02 00:42:53 +02:00
|
|
|
import java.util.List;
|
2013-05-18 23:49:04 +02:00
|
|
|
import java.util.Locale;
|
2010-03-02 00:42:53 +02:00
|
|
|
|
2011-12-06 02:42:25 +02:00
|
|
|
import static com.google.common.collect.Lists.newArrayList;
|
2010-02-08 15:30:06 +02:00
|
|
|
|
|
|
|
/**
|
2010-03-02 22:16:35 +02:00
|
|
|
* A query that parses a query string and runs it. There are two modes that this operates. The first,
|
|
|
|
* when no field is added (using {@link #field(String)}, will run the query once and non prefixed fields
|
|
|
|
* will use the {@link #defaultField(String)} set. The second, when one or more fields are added
|
|
|
|
* (using {@link #field(String)}), will run the parsed query against the provided fields, and combine
|
|
|
|
* them either using DisMax or a plain boolean query (see {@link #useDisMax(boolean)}).
|
2012-05-10 11:51:51 +03:00
|
|
|
* <p/>
|
2011-12-06 02:42:25 +02:00
|
|
|
* (shay.baon)
|
2010-02-08 15:30:06 +02:00
|
|
|
*/
|
2012-05-30 17:22:08 +02:00
|
|
|
public class QueryStringQueryBuilder extends BaseQueryBuilder implements BoostableQueryBuilder<QueryStringQueryBuilder> {
|
2010-02-08 15:30:06 +02:00
|
|
|
|
|
|
|
public static enum Operator {
|
|
|
|
OR,
|
|
|
|
AND
|
|
|
|
}
|
|
|
|
|
|
|
|
private final String queryString;
|
|
|
|
|
|
|
|
private String defaultField;
|
|
|
|
|
|
|
|
private Operator defaultOperator;
|
|
|
|
|
|
|
|
private String analyzer;
|
2012-05-10 11:51:51 +03:00
|
|
|
private String quoteAnalyzer;
|
|
|
|
|
|
|
|
private String quoteFieldSuffix;
|
2010-02-08 15:30:06 +02:00
|
|
|
|
2011-05-26 10:15:35 +03:00
|
|
|
private Boolean autoGeneratePhraseQueries;
|
|
|
|
|
2010-02-08 15:30:06 +02:00
|
|
|
private Boolean allowLeadingWildcard;
|
|
|
|
|
|
|
|
private Boolean lowercaseExpandedTerms;
|
|
|
|
|
|
|
|
private Boolean enablePositionIncrements;
|
|
|
|
|
2011-03-17 22:01:22 +02:00
|
|
|
private Boolean analyzeWildcard;
|
|
|
|
|
2010-02-08 15:30:06 +02:00
|
|
|
|
|
|
|
private float boost = -1;
|
|
|
|
|
2012-05-24 00:33:52 +02:00
|
|
|
private float fuzzyMinSim = -1;
|
2010-02-08 15:30:06 +02:00
|
|
|
private int fuzzyPrefixLength = -1;
|
2012-05-24 00:33:52 +02:00
|
|
|
private int fuzzyMaxExpansions = -1;
|
|
|
|
private String fuzzyRewrite;
|
2010-02-08 15:30:06 +02:00
|
|
|
|
|
|
|
private int phraseSlop = -1;
|
|
|
|
|
2010-03-02 00:42:53 +02:00
|
|
|
private List<String> fields;
|
|
|
|
|
2011-01-30 00:05:56 +02:00
|
|
|
private TObjectFloatHashMap<String> fieldsBoosts;
|
2010-03-02 00:42:53 +02:00
|
|
|
|
|
|
|
private Boolean useDisMax;
|
|
|
|
|
|
|
|
private float tieBreaker = -1;
|
|
|
|
|
2011-07-30 00:36:40 +03:00
|
|
|
private String rewrite = null;
|
|
|
|
|
2011-10-26 01:58:12 +02:00
|
|
|
private String minimumShouldMatch;
|
|
|
|
|
2012-05-10 13:53:46 +03:00
|
|
|
private Boolean lenient;
|
|
|
|
|
2013-08-28 10:42:33 +02:00
|
|
|
private String queryName;
|
|
|
|
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder(String queryString) {
|
2010-02-08 15:30:06 +02:00
|
|
|
this.queryString = queryString;
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:16:35 +02:00
|
|
|
/**
|
|
|
|
* The default field to run against when no prefix field is specified. Only relevant when
|
|
|
|
* not explicitly adding fields the query string will run against.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder defaultField(String defaultField) {
|
2010-02-08 15:30:06 +02:00
|
|
|
this.defaultField = defaultField;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-03-02 00:42:53 +02:00
|
|
|
/**
|
|
|
|
* Adds a field to run the query string against.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder field(String field) {
|
2010-03-02 00:42:53 +02:00
|
|
|
if (fields == null) {
|
|
|
|
fields = newArrayList();
|
|
|
|
}
|
|
|
|
fields.add(field);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a field to run the query string against with a specific boost.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder field(String field, float boost) {
|
2010-03-02 00:42:53 +02:00
|
|
|
if (fields == null) {
|
|
|
|
fields = newArrayList();
|
|
|
|
}
|
|
|
|
fields.add(field);
|
|
|
|
if (fieldsBoosts == null) {
|
2011-01-30 00:05:56 +02:00
|
|
|
fieldsBoosts = new TObjectFloatHashMap<String>(Constants.DEFAULT_CAPACITY, Constants.DEFAULT_LOAD_FACTOR, -1);
|
2010-03-02 00:42:53 +02:00
|
|
|
}
|
|
|
|
fieldsBoosts.put(field, boost);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When more than one field is used with the query string, should queries be combined using
|
|
|
|
* dis max, or boolean query. Defaults to dis max (<tt>true</tt>).
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder useDisMax(boolean useDisMax) {
|
2010-03-02 00:42:53 +02:00
|
|
|
this.useDisMax = useDisMax;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When more than one field is used with the query string, and combined queries are using
|
|
|
|
* dis max, control the tie breaker for it.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder tieBreaker(float tieBreaker) {
|
2010-03-02 00:42:53 +02:00
|
|
|
this.tieBreaker = tieBreaker;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:16:35 +02:00
|
|
|
/**
|
|
|
|
* Sets the boolean operator of the query parser used to parse the query string.
|
2011-12-06 02:42:25 +02:00
|
|
|
* <p/>
|
2010-04-29 00:05:55 +03:00
|
|
|
* <p>In default mode ({@link FieldQueryBuilder.Operator#OR}) terms without any modifiers
|
2010-03-02 22:16:35 +02:00
|
|
|
* are considered optional: for example <code>capital of Hungary</code> is equal to
|
|
|
|
* <code>capital OR of OR Hungary</code>.
|
2011-12-06 02:42:25 +02:00
|
|
|
* <p/>
|
2010-04-29 00:05:55 +03:00
|
|
|
* <p>In {@link FieldQueryBuilder.Operator#AND} mode terms are considered to be in conjunction: the
|
2010-03-02 22:16:35 +02:00
|
|
|
* above mentioned query is parsed as <code>capital AND of AND Hungary</code>
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder defaultOperator(Operator defaultOperator) {
|
2010-02-08 15:30:06 +02:00
|
|
|
this.defaultOperator = defaultOperator;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:16:35 +02:00
|
|
|
/**
|
|
|
|
* The optional analyzer used to analyze the query string. Note, if a field has search analyzer
|
|
|
|
* defined for it, then it will be used automatically. Defaults to the smart search analyzer.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder analyzer(String analyzer) {
|
2010-02-08 15:30:06 +02:00
|
|
|
this.analyzer = analyzer;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-05-10 11:51:51 +03:00
|
|
|
/**
|
|
|
|
* The optional analyzer used to analyze the query string for phrase searches. Note, if a field has search (quote) analyzer
|
|
|
|
* defined for it, then it will be used automatically. Defaults to the smart search analyzer.
|
|
|
|
*/
|
|
|
|
public QueryStringQueryBuilder quoteAnalyzer(String analyzer) {
|
|
|
|
this.quoteAnalyzer = analyzer;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-26 10:15:35 +03:00
|
|
|
/**
|
|
|
|
* Set to true if phrase queries will be automatically generated
|
|
|
|
* when the analyzer returns more than one term from whitespace
|
|
|
|
* delimited text.
|
|
|
|
* NOTE: this behavior may not be suitable for all languages.
|
2011-12-06 02:42:25 +02:00
|
|
|
* <p/>
|
2011-05-26 10:15:35 +03:00
|
|
|
* Set to false if phrase queries should only be generated when
|
|
|
|
* surrounded by double quotes.
|
|
|
|
*/
|
2011-08-13 22:36:11 +03:00
|
|
|
public QueryStringQueryBuilder autoGeneratePhraseQueries(boolean autoGeneratePhraseQueries) {
|
2011-05-26 10:15:35 +03:00
|
|
|
this.autoGeneratePhraseQueries = autoGeneratePhraseQueries;
|
2011-08-13 22:36:11 +03:00
|
|
|
return this;
|
2011-05-26 10:15:35 +03:00
|
|
|
}
|
|
|
|
|
2010-03-02 22:16:35 +02:00
|
|
|
/**
|
|
|
|
* Should leading wildcards be allowed or not. Defaults to <tt>true</tt>.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder allowLeadingWildcard(boolean allowLeadingWildcard) {
|
2010-02-08 15:30:06 +02:00
|
|
|
this.allowLeadingWildcard = allowLeadingWildcard;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:16:35 +02:00
|
|
|
/**
|
|
|
|
* Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically
|
|
|
|
* lower-cased or not. Default is <tt>true</tt>.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder lowercaseExpandedTerms(boolean lowercaseExpandedTerms) {
|
2010-02-08 15:30:06 +02:00
|
|
|
this.lowercaseExpandedTerms = lowercaseExpandedTerms;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:16:35 +02:00
|
|
|
/**
|
|
|
|
* Set to <tt>true</tt> to enable position increments in result query. Defaults to
|
|
|
|
* <tt>true</tt>.
|
2011-12-06 02:42:25 +02:00
|
|
|
* <p/>
|
2010-03-02 22:16:35 +02:00
|
|
|
* <p>When set, result phrase and multi-phrase queries will be aware of position increments.
|
|
|
|
* Useful when e.g. a StopFilter increases the position increment of the token that follows an omitted token.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder enablePositionIncrements(boolean enablePositionIncrements) {
|
2010-02-08 15:30:06 +02:00
|
|
|
this.enablePositionIncrements = enablePositionIncrements;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:16:35 +02:00
|
|
|
/**
|
|
|
|
* Set the minimum similarity for fuzzy queries. Default is 0.5f.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder fuzzyMinSim(float fuzzyMinSim) {
|
2010-02-08 15:30:06 +02:00
|
|
|
this.fuzzyMinSim = fuzzyMinSim;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:16:35 +02:00
|
|
|
/**
|
|
|
|
* Set the minimum similarity for fuzzy queries. Default is 0.5f.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder fuzzyPrefixLength(int fuzzyPrefixLength) {
|
2010-02-08 15:30:06 +02:00
|
|
|
this.fuzzyPrefixLength = fuzzyPrefixLength;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-05-24 00:33:52 +02:00
|
|
|
public QueryStringQueryBuilder fuzzyMaxExpansions(int fuzzyMaxExpansions) {
|
|
|
|
this.fuzzyMaxExpansions = fuzzyMaxExpansions;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public QueryStringQueryBuilder fuzzyRewrite(String fuzzyRewrite) {
|
|
|
|
this.fuzzyRewrite = fuzzyRewrite;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:16:35 +02:00
|
|
|
/**
|
|
|
|
* Sets the default slop for phrases. If zero, then exact phrase matches
|
|
|
|
* are required. Default value is zero.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder phraseSlop(int phraseSlop) {
|
2010-02-08 15:30:06 +02:00
|
|
|
this.phraseSlop = phraseSlop;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2011-03-17 22:01:22 +02:00
|
|
|
/**
|
|
|
|
* Set to <tt>true</tt> to enable analysis on wildcard and prefix queries.
|
|
|
|
*/
|
|
|
|
public QueryStringQueryBuilder analyzeWildcard(boolean analyzeWildcard) {
|
|
|
|
this.analyzeWildcard = analyzeWildcard;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2011-07-30 00:36:40 +03:00
|
|
|
public QueryStringQueryBuilder rewrite(String rewrite) {
|
|
|
|
this.rewrite = rewrite;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2011-10-26 01:58:12 +02:00
|
|
|
public QueryStringQueryBuilder minimumShouldMatch(String minimumShouldMatch) {
|
|
|
|
this.minimumShouldMatch = minimumShouldMatch;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-03-02 22:16:35 +02:00
|
|
|
/**
|
|
|
|
* Sets the boost for this query. Documents matching this query will (in addition to the normal
|
|
|
|
* weightings) have their score multiplied by the boost provided.
|
|
|
|
*/
|
2010-04-29 00:05:55 +03:00
|
|
|
public QueryStringQueryBuilder boost(float boost) {
|
2010-03-02 22:16:35 +02:00
|
|
|
this.boost = boost;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-05-10 11:51:51 +03:00
|
|
|
/**
|
|
|
|
* An optional field name suffix to automatically try and add to the field searched when using quoted text.
|
|
|
|
*/
|
|
|
|
public QueryStringQueryBuilder quoteFieldSuffix(String quoteFieldSuffix) {
|
|
|
|
this.quoteFieldSuffix = quoteFieldSuffix;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-05-10 13:53:46 +03:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2013-08-28 10:42:33 +02:00
|
|
|
/**
|
|
|
|
* Sets the query name for the filter that can be used when searching for matched_filters per hit.
|
|
|
|
*/
|
|
|
|
public QueryStringQueryBuilder queryName(String queryName) {
|
|
|
|
this.queryName = queryName;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2011-12-06 02:42:25 +02:00
|
|
|
@Override
|
|
|
|
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
|
2010-04-29 00:05:55 +03:00
|
|
|
builder.startObject(QueryStringQueryParser.NAME);
|
2010-02-08 15:30:06 +02:00
|
|
|
builder.field("query", queryString);
|
|
|
|
if (defaultField != null) {
|
2010-04-04 17:18:18 +03:00
|
|
|
builder.field("default_field", defaultField);
|
2010-02-08 15:30:06 +02:00
|
|
|
}
|
2010-03-02 00:42:53 +02:00
|
|
|
if (fields != null) {
|
|
|
|
builder.startArray("fields");
|
|
|
|
for (String field : fields) {
|
|
|
|
float boost = -1;
|
|
|
|
if (fieldsBoosts != null) {
|
|
|
|
boost = fieldsBoosts.get(field);
|
|
|
|
}
|
|
|
|
if (boost != -1) {
|
|
|
|
field += "^" + boost;
|
|
|
|
}
|
2010-03-02 22:16:35 +02:00
|
|
|
builder.value(field);
|
2010-03-02 00:42:53 +02:00
|
|
|
}
|
|
|
|
builder.endArray();
|
|
|
|
}
|
|
|
|
if (useDisMax != null) {
|
2010-04-04 17:18:18 +03:00
|
|
|
builder.field("use_dis_max", useDisMax);
|
2010-03-02 00:42:53 +02:00
|
|
|
}
|
|
|
|
if (tieBreaker != -1) {
|
2010-04-04 17:18:18 +03:00
|
|
|
builder.field("tie_breaker", tieBreaker);
|
2010-03-02 00:42:53 +02:00
|
|
|
}
|
2010-02-08 15:30:06 +02:00
|
|
|
if (defaultOperator != null) {
|
2013-05-18 23:49:04 +02:00
|
|
|
builder.field("default_operator", defaultOperator.name().toLowerCase(Locale.ROOT));
|
2010-02-08 15:30:06 +02:00
|
|
|
}
|
|
|
|
if (analyzer != null) {
|
|
|
|
builder.field("analyzer", analyzer);
|
|
|
|
}
|
2012-05-10 11:51:51 +03:00
|
|
|
if (quoteAnalyzer != null) {
|
|
|
|
builder.field("quote_analyzer", quoteAnalyzer);
|
|
|
|
}
|
2011-05-26 10:15:35 +03:00
|
|
|
if (autoGeneratePhraseQueries != null) {
|
|
|
|
builder.field("auto_generate_phrase_queries", autoGeneratePhraseQueries);
|
|
|
|
}
|
2010-02-08 15:30:06 +02:00
|
|
|
if (allowLeadingWildcard != null) {
|
2010-04-04 17:18:18 +03:00
|
|
|
builder.field("allow_leading_wildcard", allowLeadingWildcard);
|
2010-02-08 15:30:06 +02:00
|
|
|
}
|
|
|
|
if (lowercaseExpandedTerms != null) {
|
2010-04-04 17:18:18 +03:00
|
|
|
builder.field("lowercase_expanded_terms", lowercaseExpandedTerms);
|
2010-02-08 15:30:06 +02:00
|
|
|
}
|
|
|
|
if (enablePositionIncrements != null) {
|
2010-04-04 17:18:18 +03:00
|
|
|
builder.field("enable_position_increments", enablePositionIncrements);
|
2010-02-08 15:30:06 +02:00
|
|
|
}
|
|
|
|
if (fuzzyMinSim != -1) {
|
2010-04-04 17:18:18 +03:00
|
|
|
builder.field("fuzzy_min_sim", fuzzyMinSim);
|
2010-02-08 15:30:06 +02:00
|
|
|
}
|
|
|
|
if (boost != -1) {
|
|
|
|
builder.field("boost", boost);
|
|
|
|
}
|
|
|
|
if (fuzzyPrefixLength != -1) {
|
2010-04-04 17:18:18 +03:00
|
|
|
builder.field("fuzzy_prefix_length", fuzzyPrefixLength);
|
2010-02-08 15:30:06 +02:00
|
|
|
}
|
2012-05-24 00:33:52 +02:00
|
|
|
if (fuzzyMaxExpansions != -1) {
|
|
|
|
builder.field("fuzzy_max_expansions", fuzzyMaxExpansions);
|
|
|
|
}
|
|
|
|
if (fuzzyRewrite != null) {
|
|
|
|
builder.field("fuzzy_rewrite", fuzzyRewrite);
|
|
|
|
}
|
2010-02-08 15:30:06 +02:00
|
|
|
if (phraseSlop != -1) {
|
2010-04-04 17:18:18 +03:00
|
|
|
builder.field("phrase_slop", phraseSlop);
|
2010-02-08 15:30:06 +02:00
|
|
|
}
|
2011-03-17 22:01:22 +02:00
|
|
|
if (analyzeWildcard != null) {
|
|
|
|
builder.field("analyze_wildcard", analyzeWildcard);
|
|
|
|
}
|
2011-07-30 00:36:40 +03:00
|
|
|
if (rewrite != null) {
|
|
|
|
builder.field("rewrite", rewrite);
|
|
|
|
}
|
2011-10-26 01:58:12 +02:00
|
|
|
if (minimumShouldMatch != null) {
|
2011-11-10 12:13:31 +02:00
|
|
|
builder.field("minimum_should_match", minimumShouldMatch);
|
2011-10-26 01:58:12 +02:00
|
|
|
}
|
2012-05-10 11:51:51 +03:00
|
|
|
if (quoteFieldSuffix != null) {
|
|
|
|
builder.field("quote_field_suffix", quoteFieldSuffix);
|
|
|
|
}
|
2012-05-10 13:53:46 +03:00
|
|
|
if (lenient != null) {
|
|
|
|
builder.field("lenient", lenient);
|
|
|
|
}
|
2013-08-28 10:42:33 +02:00
|
|
|
if (queryName != null) {
|
|
|
|
builder.field("_name", queryName);
|
|
|
|
}
|
2010-02-08 15:30:06 +02:00
|
|
|
builder.endObject();
|
|
|
|
}
|
|
|
|
}
|