public class SimpleQueryStringBuilder extends AbstractQueryBuilder<SimpleQueryStringBuilder>
+
' specifies AND
operation: token1+token2
|
' specifies OR
operation: token1|token2
-
' negates a single token: -token0
"
' creates phrases of terms: "term1 term2 ..."
*
' at the end of terms specifies prefix query: term*
(
' and '' specifies precedence: token1 + (token2 | token3)
~
N' at the end of terms specifies fuzzy query: term~1
~
N' at the end of phrases specifies near/slop query: "term1 term2"~5
See: SimpleQueryParser
for more information.
This query supports these options:
Required:
query
- query text to be converted into other queries
Optional:
analyzer
- anaylzer to be used for analyzing tokens to determine
which kind of query they should be converted into, defaults to "standard"
default_operator
- default operator for boolean queries, defaults
to OR
fields
- fields to search, defaults to _all if not set, allows
boosting a field with ^n
For more detailed explanation of the query string syntax see also the online documentation.
Writeable.Reader<V>, Writeable.Writer<V>
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_ANALYZE_WILDCARD
Default for wildcard analysis.
|
static int |
DEFAULT_FLAGS
Default for search flags to use.
|
static boolean |
DEFAULT_LENIENT
Default for using lenient query parsing.
|
static Operator |
DEFAULT_OPERATOR
Default for default operator to use for linking boolean clauses.
|
static java.lang.String |
NAME
Name for (de-)serialization.
|
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
EMPTY_PARAMS
MAX_REWRITE_ROUNDS
Constructor and Description |
---|
SimpleQueryStringBuilder(StreamInput in)
Read from a stream.
|
SimpleQueryStringBuilder(java.lang.String queryText)
Construct a new simple query with this query string.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
analyzer()
Returns the analyzer to use for the query.
|
SimpleQueryStringBuilder |
analyzer(java.lang.String analyzer)
Specify an analyzer to use for the query.
|
boolean |
analyzeWildcard()
Returns whether wildcards should by analyzed.
|
SimpleQueryStringBuilder |
analyzeWildcard(boolean analyzeWildcard)
Specifies whether wildcards should be analyzed.
|
Operator |
defaultOperator()
Returns the default operator for the query.
|
SimpleQueryStringBuilder |
defaultOperator(Operator defaultOperator)
Specify the default operator for the query.
|
protected boolean |
doEquals(SimpleQueryStringBuilder other)
Indicates whether some other
QueryBuilder object of the same type is "equal to" this one. |
protected int |
doHashCode() |
protected org.apache.lucene.search.Query |
doToQuery(QueryShardContext context) |
protected void |
doWriteTo(StreamOutput out) |
protected void |
doXContent(XContentBuilder builder,
ToXContent.Params params) |
SimpleQueryStringBuilder |
field(java.lang.String field)
Add a field to run the query against.
|
SimpleQueryStringBuilder |
field(java.lang.String field,
float boost)
Add a field to run the query against with a specific boost.
|
java.util.Map<java.lang.String,java.lang.Float> |
fields()
Returns the fields including their respective boosts to run the query against.
|
SimpleQueryStringBuilder |
fields(java.util.Map<java.lang.String,java.lang.Float> fields)
Add several fields to run the query against with a specific boost.
|
SimpleQueryStringBuilder |
flags(SimpleQueryStringFlag... flags)
Specify the enabled features of the SimpleQueryString.
|
static SimpleQueryStringBuilder |
fromXContent(XContentParser parser) |
java.lang.String |
getWriteableName()
Returns the name of the writeable object
|
boolean |
lenient()
Returns whether query parsing should be lenient.
|
SimpleQueryStringBuilder |
lenient(boolean lenient)
Specifies whether query parsing should be lenient.
|
java.lang.String |
minimumShouldMatch()
Returns the minimumShouldMatch to apply to the resulting query should
that be a Boolean query.
|
SimpleQueryStringBuilder |
minimumShouldMatch(java.lang.String minimumShouldMatch)
Specifies the minimumShouldMatch to apply to the resulting query should
that be a Boolean query.
|
java.lang.String |
quoteFieldSuffix()
Return the suffix to append to field names for phrase matching.
|
SimpleQueryStringBuilder |
quoteFieldSuffix(java.lang.String suffix)
Set the suffix to append to field names for phrase matching.
|
java.lang.Boolean |
useAllFields() |
SimpleQueryStringBuilder |
useAllFields(java.lang.Boolean useAllFields) |
java.lang.String |
value()
Returns the text to parse the query from.
|
addValidationError, boost, boost, convertToBytesRefIfString, convertToStringIfBytesRef, declareStandardFields, doRewrite, equals, extractInnerHitBuilders, getName, hashCode, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, readQueries, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toFilter, toQueries, toQuery, toXContent, writeQueries, writeTo
buildAsBytes, buildAsBytes, toString, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isFragment
rewrite, rewrite, rewrite, rewriteAndFetch, rewriteAndFetch
public static final boolean DEFAULT_LENIENT
public static final boolean DEFAULT_ANALYZE_WILDCARD
public static final Operator DEFAULT_OPERATOR
public static final int DEFAULT_FLAGS
public static final java.lang.String NAME
public SimpleQueryStringBuilder(java.lang.String queryText)
public SimpleQueryStringBuilder(StreamInput in) throws java.io.IOException
java.io.IOException
protected void doWriteTo(StreamOutput out) throws java.io.IOException
doWriteTo
in class AbstractQueryBuilder<SimpleQueryStringBuilder>
java.io.IOException
public java.lang.String value()
public SimpleQueryStringBuilder field(java.lang.String field)
public SimpleQueryStringBuilder field(java.lang.String field, float boost)
public SimpleQueryStringBuilder fields(java.util.Map<java.lang.String,java.lang.Float> fields)
public java.util.Map<java.lang.String,java.lang.Float> fields()
public SimpleQueryStringBuilder analyzer(java.lang.String analyzer)
public java.lang.String analyzer()
public java.lang.Boolean useAllFields()
public SimpleQueryStringBuilder useAllFields(java.lang.Boolean useAllFields)
public SimpleQueryStringBuilder defaultOperator(Operator defaultOperator)
public Operator defaultOperator()
public SimpleQueryStringBuilder flags(SimpleQueryStringFlag... flags)
public SimpleQueryStringBuilder quoteFieldSuffix(java.lang.String suffix)
public java.lang.String quoteFieldSuffix()
public SimpleQueryStringBuilder lenient(boolean lenient)
public boolean lenient()
public SimpleQueryStringBuilder analyzeWildcard(boolean analyzeWildcard)
public boolean analyzeWildcard()
public SimpleQueryStringBuilder minimumShouldMatch(java.lang.String minimumShouldMatch)
public java.lang.String minimumShouldMatch()
protected org.apache.lucene.search.Query doToQuery(QueryShardContext context) throws java.io.IOException
doToQuery
in class AbstractQueryBuilder<SimpleQueryStringBuilder>
java.io.IOException
protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
doXContent
in class AbstractQueryBuilder<SimpleQueryStringBuilder>
java.io.IOException
public static SimpleQueryStringBuilder fromXContent(XContentParser parser) throws java.io.IOException
java.io.IOException
public java.lang.String getWriteableName()
NamedWriteable
protected int doHashCode()
doHashCode
in class AbstractQueryBuilder<SimpleQueryStringBuilder>
protected boolean doEquals(SimpleQueryStringBuilder other)
AbstractQueryBuilder
QueryBuilder
object of the same type is "equal to" this one.doEquals
in class AbstractQueryBuilder<SimpleQueryStringBuilder>