Class QueryStringQueryBuilder
- All Implemented Interfaces:
NamedWriteable
,Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentObject
,QueryBuilder
,Rewriteable<QueryBuilder>
field(String)
, will run the query once and non prefixed fields
will use the defaultField(String)
set. The second, when one or more fields are added
(using field(String)
), will run the parsed query against the provided fields, and combine
them using Dismax.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic boolean
static boolean
static Fuzziness
static int
static int
static boolean
static int
static Operator
static int
static MultiMatchQueryBuilder.Type
static String
Fields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionallowLeadingWildcard(Boolean allowLeadingWildcard)
Should leading wildcards be allowed or not.analyzer()
The optional analyzer used to analyze the query string.The optional analyzer used to analyze the query string.analyzeWildcard(Boolean analyzeWildcard)
Set totrue
to enable analysis on wildcard and prefix queries.boolean
Whether phrase queries should be automatically generated for multi terms synonyms.autoGenerateSynonymsPhraseQuery(boolean value)
defaultField(String defaultField)
The default field to run against when no prefix field is specified.defaultOperator(Operator defaultOperator)
Sets the boolean operator of the query parser used to parse the query string.protected boolean
doEquals(QueryStringQueryBuilder other)
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.protected int
protected org.apache.lucene.search.Query
doToQuery(SearchExecutionContext context)
protected void
doWriteTo(StreamOutput out)
protected void
doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
boolean
enablePositionIncrements(boolean enablePositionIncrements)
Set totrue
to enable position increments in result query.boolean
escape()
escape(boolean escape)
Set totrue
to enable escaping of the query stringAdds a field to run the query string against.Adds a field to run the query string against with a specific boost.fields()
Returns the fields including their respective boosts to run the query against.Add several fields to run the query against with a specific boost.static QueryStringQueryBuilder
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
Set the edit distance for fuzzy queries.int
fuzzyMaxExpansions(int fuzzyMaxExpansions)
int
fuzzyPrefixLength(int fuzzyPrefixLength)
Set the minimum prefix length for fuzzy queries.fuzzyRewrite(String fuzzyRewrite)
boolean
fuzzyTranspositions(boolean fuzzyTranspositions)
Sets whether transpositions are supported in fuzzy queries.Returns the name of the writeable objectlenient()
Sets the query string parser to be lenient when parsing field values, defaults to the index setting and if not set, defaults to false.int
maxDeterminizedStates(int maxDeterminizedStates)
Protects against too-difficult regular expression queries.minimumShouldMatch(String minimumShouldMatch)
int
phraseSlop(int phraseSlop)
Sets the default slop for phrases.The optional analyzer used to analyze the query string for phrase searches.quoteAnalyzer(String quoteAnalyzer)
The optional analyzer used to analyze the query string for phrase searches.quoteFieldSuffix(String quoteFieldSuffix)
An optional field name suffix to automatically try and add to the field searched when using quoted text.rewrite()
tieBreaker(float tieBreaker)
When more than one field is used with the query string, and combined queries are using dis max, control the tie breaker for it.timeZone()
In case of date field, we can adjust the from/to fields using a timezoneMethods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, doRewrite, equals, extractInnerHitBuilders, getName, hashCode, parseInnerQueryBuilder, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeTo
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
- See Also:
- Constant Field Values
-
DEFAULT_MAX_DETERMINED_STATES
public static final int DEFAULT_MAX_DETERMINED_STATES- See Also:
- Constant Field Values
-
DEFAULT_ENABLE_POSITION_INCREMENTS
public static final boolean DEFAULT_ENABLE_POSITION_INCREMENTS- See Also:
- Constant Field Values
-
DEFAULT_ESCAPE
public static final boolean DEFAULT_ESCAPE- See Also:
- Constant Field Values
-
DEFAULT_FUZZY_PREFIX_LENGTH
public static final int DEFAULT_FUZZY_PREFIX_LENGTH- See Also:
- Constant Field Values
-
DEFAULT_FUZZY_MAX_EXPANSIONS
public static final int DEFAULT_FUZZY_MAX_EXPANSIONS- See Also:
- Constant Field Values
-
DEFAULT_PHRASE_SLOP
public static final int DEFAULT_PHRASE_SLOP- See Also:
- Constant Field Values
-
DEFAULT_FUZZINESS
-
DEFAULT_OPERATOR
-
DEFAULT_TYPE
-
DEFAULT_FUZZY_TRANSPOSITIONS
public static final boolean DEFAULT_FUZZY_TRANSPOSITIONS- See Also:
- Constant Field Values
-
-
Constructor Details
-
QueryStringQueryBuilder
-
QueryStringQueryBuilder
Read from a stream.- Throws:
IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteTo
in classAbstractQueryBuilder<QueryStringQueryBuilder>
- Throws:
IOException
-
queryString
-
defaultField
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. -
defaultField
-
field
Adds a field to run the query string against. The field will be associated with the default boost ofAbstractQueryBuilder.DEFAULT_BOOST
. Usefield(String, float)
to set a specific boost for the field. -
field
Adds a field to run the query string against with a specific boost. -
fields
Add several fields to run the query against with a specific boost. -
fields
Returns the fields including their respective boosts to run the query against. -
type
- Parameters:
type
- Sets how multiple fields should be combined to build textual part queries.
-
tieBreaker
When more than one field is used with the query string, and combined queries are using dis max, control the tie breaker for it. -
tieBreaker
-
defaultOperator
Sets the boolean operator of the query parser used to parse the query string.In default mode (
Operator.OR
) terms without any modifiers are considered optional: for examplecapital of Hungary
is equal tocapital OR of OR Hungary
.In
Operator.AND
mode terms are considered to be in conjunction: the above mentioned query is parsed ascapital AND of AND Hungary
-
defaultOperator
-
analyzer
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. -
analyzer
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. -
quoteAnalyzer
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. -
quoteAnalyzer
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. -
maxDeterminizedStates
Protects against too-difficult regular expression queries. -
maxDeterminizedStates
public int maxDeterminizedStates() -
allowLeadingWildcard
Should leading wildcards be allowed or not. Defaults totrue
. -
allowLeadingWildcard
-
enablePositionIncrements
Set totrue
to enable position increments in result query. Defaults totrue
.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.
-
enablePositionIncrements
public boolean enablePositionIncrements() -
fuzziness
Set the edit distance for fuzzy queries. Default is "AUTO". -
fuzziness
-
fuzzyPrefixLength
Set the minimum prefix length for fuzzy queries. Default is 1. -
fuzzyPrefixLength
public int fuzzyPrefixLength() -
fuzzyMaxExpansions
-
fuzzyMaxExpansions
public int fuzzyMaxExpansions() -
fuzzyRewrite
-
fuzzyRewrite
-
phraseSlop
Sets the default slop for phrases. If zero, then exact phrase matches are required. Default value is zero. -
phraseSlop
public int phraseSlop() -
rewrite
-
analyzeWildcard
Set totrue
to enable analysis on wildcard and prefix queries. -
analyzeWildcard
-
rewrite
-
minimumShouldMatch
-
minimumShouldMatch
-
quoteFieldSuffix
An optional field name suffix to automatically try and add to the field searched when using quoted text. -
quoteFieldSuffix
-
lenient
Sets the query string parser to be lenient when parsing field values, defaults to the index setting and if not set, defaults to false. -
lenient
-
timeZone
In case of date field, we can adjust the from/to fields using a timezone -
timeZone
-
timeZone
-
escape
Set totrue
to enable escaping of the query string -
escape
public boolean escape() -
autoGenerateSynonymsPhraseQuery
-
autoGenerateSynonymsPhraseQuery
public boolean autoGenerateSynonymsPhraseQuery()Whether phrase queries should be automatically generated for multi terms synonyms. Defaults totrue
. -
fuzzyTranspositions
public boolean fuzzyTranspositions() -
fuzzyTranspositions
Sets whether transpositions are supported in fuzzy queries.The default metric used by fuzzy queries to determine a match is the Damerau-Levenshtein distance formula which supports transpositions. Setting transposition to false will switch to classic Levenshtein distance.
If not set, Damerau-Levenshtein distance metric will be used. -
doXContent
protected void doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Specified by:
doXContent
in classAbstractQueryBuilder<QueryStringQueryBuilder>
- Throws:
IOException
-
fromXContent
public static QueryStringQueryBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException- Throws:
IOException
-
getWriteableName
Description copied from interface:NamedWriteable
Returns the name of the writeable object -
doEquals
Description copied from class:AbstractQueryBuilder
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.- Specified by:
doEquals
in classAbstractQueryBuilder<QueryStringQueryBuilder>
-
doHashCode
protected int doHashCode()- Specified by:
doHashCode
in classAbstractQueryBuilder<QueryStringQueryBuilder>
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(SearchExecutionContext context) throws IOException- Specified by:
doToQuery
in classAbstractQueryBuilder<QueryStringQueryBuilder>
- Throws:
IOException
-