public abstract class QueryBuilders extends Object
Modifier and Type | Method and Description |
---|---|
static AndQueryBuilder |
andQuery(QueryBuilder... filters)
Deprecated.
Use
BoolQueryBuilder.mustNot(QueryBuilder) instead |
static BoolQueryBuilder |
boolQuery()
A Query that matches documents matching boolean combinations of other queries.
|
static BoostingQueryBuilder |
boostingQuery()
The BoostingQuery class can be used to effectively demote results that match a given query.
|
static CommonTermsQueryBuilder |
commonTermsQuery(String name,
Object text)
Creates a common query for the provided field name and text.
|
static ConstantScoreQueryBuilder |
constantScoreQuery(QueryBuilder queryBuilder)
A query that wraps another query and simply returns a constant score equal to the
query boost for every document in the query.
|
static DisMaxQueryBuilder |
disMaxQuery()
A query that generates the union of documents produced by its sub-queries, and that scores each document
with the maximum score for that document as produced by any sub-query, plus a tie breaking increment for any
additional matching sub-queries.
|
static ExistsQueryBuilder |
existsQuery(String name)
A filter to filter only documents where a field exists in them.
|
static FieldMaskingSpanQueryBuilder |
fieldMaskingSpanQuery(SpanQueryBuilder query,
String field) |
static FilteredQueryBuilder |
filteredQuery(QueryBuilder queryBuilder,
QueryBuilder filterBuilder)
Deprecated.
|
static FunctionScoreQueryBuilder |
functionScoreQuery()
A query that allows to define a custom scoring function.
|
static FunctionScoreQueryBuilder |
functionScoreQuery(QueryBuilder queryBuilder)
A query that allows to define a custom scoring function.
|
static FunctionScoreQueryBuilder |
functionScoreQuery(QueryBuilder queryBuilder,
ScoreFunctionBuilder function)
A query that allows to define a custom scoring function.
|
static FunctionScoreQueryBuilder |
functionScoreQuery(ScoreFunctionBuilder function)
A query that allows to define a custom scoring function.
|
static FuzzyQueryBuilder |
fuzzyQuery(String name,
Object value)
A Query that matches documents using fuzzy query.
|
static FuzzyQueryBuilder |
fuzzyQuery(String name,
String value)
A Query that matches documents using fuzzy query.
|
static GeoBoundingBoxQueryBuilder |
geoBoundingBoxQuery(String name)
A filter to filter based on a bounding box defined by top left and bottom right locations / points
|
static GeoShapeQueryBuilder |
geoDisjointQuery(String name,
ShapeBuilder shape)
A filter to filter indexed shapes that are not intersection with the query shape
|
static GeoShapeQueryBuilder |
geoDisjointQuery(String name,
String indexedShapeId,
String indexedShapeType) |
static GeoDistanceQueryBuilder |
geoDistanceQuery(String name)
A filter to filter based on a specific distance from a specific geo location / point.
|
static GeoDistanceRangeQueryBuilder |
geoDistanceRangeQuery(String name)
A filter to filter based on a specific range from a specific geo location / point.
|
static GeohashCellQuery.Builder |
geoHashCellQuery(String name)
A filter based on a bounding box defined by geohash.
|
static GeohashCellQuery.Builder |
geoHashCellQuery(String name,
GeoPoint point)
A filter based on a bounding box defined by geohash.
|
static GeohashCellQuery.Builder |
geoHashCellQuery(String name,
String geohash)
A filter based on a bounding box defined by geohash.
|
static GeohashCellQuery.Builder |
geoHashCellQuery(String name,
String geohash,
boolean neighbors)
A filter based on a bounding box defined by geohash.
|
static GeoShapeQueryBuilder |
geoIntersectionQuery(String name,
ShapeBuilder shape)
A filter to filter indexed shapes intersecting with shapes
|
static GeoShapeQueryBuilder |
geoIntersectionQuery(String name,
String indexedShapeId,
String indexedShapeType) |
static GeoPolygonQueryBuilder |
geoPolygonQuery(String name)
A filter to filter based on a polygon defined by a set of locations / points.
|
static GeoShapeQueryBuilder |
geoShapeQuery(String name,
ShapeBuilder shape)
Query that matches Documents based on the relationship between the given shape and
indexed shapes
|
static GeoShapeQueryBuilder |
geoShapeQuery(String name,
ShapeBuilder shape,
ShapeRelation relation)
A filter based on the relationship of a shape and indexed shapes
|
static GeoShapeQueryBuilder |
geoShapeQuery(String name,
String indexedShapeId,
String indexedShapeType) |
static GeoShapeQueryBuilder |
geoShapeQuery(String name,
String indexedShapeId,
String indexedShapeType,
ShapeRelation relation) |
static GeoShapeQueryBuilder |
geoWithinQuery(String name,
ShapeBuilder shape)
A filter to filter indexed shapes that are contained by a shape
|
static GeoShapeQueryBuilder |
geoWithinQuery(String name,
String indexedShapeId,
String indexedShapeType) |
static HasChildQueryBuilder |
hasChildQuery(String type,
QueryBuilder query)
Constructs a new NON scoring child query, with the child type and the query to run on the child documents.
|
static HasParentQueryBuilder |
hasParentQuery(String type,
QueryBuilder query)
Constructs a new NON scoring parent query, with the parent type and the query to run on the parent documents.
|
static IdsQueryBuilder |
idsQuery(String... types)
Constructs a query that will match only specific ids within types.
|
static IndicesQueryBuilder |
indicesQuery(QueryBuilder queryBuilder,
String... indices)
A query that will execute the wrapped query only for the specified indices, and "match_all" when
it does not match those indices.
|
static LimitQueryBuilder |
limitQuery(int limit)
Deprecated.
Use
SearchRequestBuilder.setTerminateAfter(int) instead |
static MatchAllQueryBuilder |
matchAllQuery()
A query that match on all documents.
|
static MatchQueryBuilder |
matchPhrasePrefixQuery(String name,
Object text)
Creates a match query with type "PHRASE_PREFIX" for the provided field name and text.
|
static MatchQueryBuilder |
matchPhraseQuery(String name,
Object text)
Creates a text query with type "PHRASE" for the provided field name and text.
|
static MatchQueryBuilder |
matchQuery(String name,
Object text)
Creates a match query with type "BOOLEAN" for the provided field name and text.
|
static MissingQueryBuilder |
missingQuery(String name)
Deprecated.
Use
existsQuery(String) inside a BoolQueryBuilder.mustNot(QueryBuilder) clause instead. |
static MoreLikeThisQueryBuilder |
moreLikeThisQuery()
A more like this query that finds documents that are "like" the provided
MoreLikeThisQueryBuilder.likeText(String)
which is checked against the "_all" field. |
static MoreLikeThisQueryBuilder |
moreLikeThisQuery(String... fields)
A more like this query that finds documents that are "like" the provided
MoreLikeThisQueryBuilder.likeText(String)
which is checked against the fields the query is constructed with. |
static MultiMatchQueryBuilder |
multiMatchQuery(Object text,
String... fieldNames)
Creates a match query with type "BOOLEAN" for the provided field name and text.
|
static NestedQueryBuilder |
nestedQuery(String path,
QueryBuilder query) |
static NotQueryBuilder |
notQuery(QueryBuilder filter)
Deprecated.
use
boolQuery() and add a mustNot clause instead |
static OrQueryBuilder |
orQuery(QueryBuilder... filters)
Deprecated.
Use
boolQuery() instead |
static PrefixQueryBuilder |
prefixQuery(String name,
String prefix)
A Query that matches documents containing terms with a specified prefix.
|
static QueryFilterBuilder |
queryFilter(QueryBuilder query)
Deprecated.
Useless now that queries and filters are merged: pass the
query as a filter directly.
|
static QueryStringQueryBuilder |
queryStringQuery(String queryString)
A query that parses a query string and runs it.
|
static RangeQueryBuilder |
rangeQuery(String name)
A Query that matches documents within an range of terms.
|
static RegexpQueryBuilder |
regexpQuery(String name,
String regexp)
A Query that matches documents containing terms with a specified regular expression.
|
static ScriptQueryBuilder |
scriptQuery(Script script)
A builder for filter based on a script.
|
static SimpleQueryStringBuilder |
simpleQueryStringQuery(String queryString)
A query that acts similar to a query_string query, but won't throw
exceptions for any weird string syntax.
|
static SpanContainingQueryBuilder |
spanContainingQuery()
Creates a new
span_containing builder. |
static SpanFirstQueryBuilder |
spanFirstQuery(SpanQueryBuilder match,
int end) |
static SpanMultiTermQueryBuilder |
spanMultiTermQueryBuilder(MultiTermQueryBuilder multiTermQueryBuilder)
Creates a
SpanQueryBuilder which allows having a sub query
which implements MultiTermQueryBuilder . |
static SpanNearQueryBuilder |
spanNearQuery() |
static SpanNotQueryBuilder |
spanNotQuery() |
static SpanOrQueryBuilder |
spanOrQuery() |
static SpanTermQueryBuilder |
spanTermQuery(String name,
double value) |
static SpanTermQueryBuilder |
spanTermQuery(String name,
float value) |
static SpanTermQueryBuilder |
spanTermQuery(String name,
int value) |
static SpanTermQueryBuilder |
spanTermQuery(String name,
long value) |
static SpanTermQueryBuilder |
spanTermQuery(String name,
String value) |
static SpanWithinQueryBuilder |
spanWithinQuery()
Creates a new
span_within builder. |
static TemplateQueryBuilder |
templateQuery(String template,
Map<String,Object> vars)
Facilitates creating template query requests using an inline script
|
static TemplateQueryBuilder |
templateQuery(String template,
ScriptService.ScriptType templateType,
Map<String,Object> vars)
Facilitates creating template query requests
|
static TemplateQueryBuilder |
templateQuery(Template template)
Facilitates creating template query requests using an inline script
|
static TermQueryBuilder |
termQuery(String name,
boolean value)
A Query that matches documents containing a term.
|
static TermQueryBuilder |
termQuery(String name,
double value)
A Query that matches documents containing a term.
|
static TermQueryBuilder |
termQuery(String name,
float value)
A Query that matches documents containing a term.
|
static TermQueryBuilder |
termQuery(String name,
int value)
A Query that matches documents containing a term.
|
static TermQueryBuilder |
termQuery(String name,
long value)
A Query that matches documents containing a term.
|
static TermQueryBuilder |
termQuery(String name,
Object value)
A Query that matches documents containing a term.
|
static TermQueryBuilder |
termQuery(String name,
String value)
A Query that matches documents containing a term.
|
static TermsLookupQueryBuilder |
termsLookupQuery(String name)
A terms lookup filter for the provided field name.
|
static TermsQueryBuilder |
termsQuery(String name,
Collection<?> values)
A filer for a field based on several terms matching on any of them.
|
static TermsQueryBuilder |
termsQuery(String name,
double... values)
A filer for a field based on several terms matching on any of them.
|
static TermsQueryBuilder |
termsQuery(String name,
float... values)
A filer for a field based on several terms matching on any of them.
|
static TermsQueryBuilder |
termsQuery(String name,
int... values)
A filer for a field based on several terms matching on any of them.
|
static TermsQueryBuilder |
termsQuery(String name,
long... values)
A filer for a field based on several terms matching on any of them.
|
static TermsQueryBuilder |
termsQuery(String name,
Object... values)
A filer for a field based on several terms matching on any of them.
|
static TermsQueryBuilder |
termsQuery(String name,
String... values)
A filer for a field based on several terms matching on any of them.
|
static TypeQueryBuilder |
typeQuery(String type)
A filter based on doc/mapping type.
|
static WildcardQueryBuilder |
wildcardQuery(String name,
String query)
Implements the wildcard search query.
|
static WrapperQueryBuilder |
wrapperQuery(byte[] source,
int offset,
int length)
A Query builder which allows building a query thanks to a JSON string or binary data.
|
static WrapperQueryBuilder |
wrapperQuery(BytesReference source)
A Query builder which allows building a query thanks to a JSON string or binary data.
|
static WrapperQueryBuilder |
wrapperQuery(String source)
A Query builder which allows building a query thanks to a JSON string or binary data.
|
public static MatchAllQueryBuilder matchAllQuery()
public static MatchQueryBuilder matchQuery(String name, Object text)
name
- The field name.text
- The query text (to be analyzed).public static CommonTermsQueryBuilder commonTermsQuery(String name, Object text)
name
- The field name.text
- The query text (to be analyzed).public static MultiMatchQueryBuilder multiMatchQuery(Object text, String... fieldNames)
fieldNames
- The field names.text
- The query text (to be analyzed).public static MatchQueryBuilder matchPhraseQuery(String name, Object text)
name
- The field name.text
- The query text (to be analyzed).public static MatchQueryBuilder matchPhrasePrefixQuery(String name, Object text)
name
- The field name.text
- The query text (to be analyzed).public static DisMaxQueryBuilder disMaxQuery()
public static IdsQueryBuilder idsQuery(@Nullable String... types)
types
- The mapping/doc typepublic static TermQueryBuilder termQuery(String name, String value)
name
- The name of the fieldvalue
- The value of the termpublic static TermQueryBuilder termQuery(String name, int value)
name
- The name of the fieldvalue
- The value of the termpublic static TermQueryBuilder termQuery(String name, long value)
name
- The name of the fieldvalue
- The value of the termpublic static TermQueryBuilder termQuery(String name, float value)
name
- The name of the fieldvalue
- The value of the termpublic static TermQueryBuilder termQuery(String name, double value)
name
- The name of the fieldvalue
- The value of the termpublic static TermQueryBuilder termQuery(String name, boolean value)
name
- The name of the fieldvalue
- The value of the termpublic static TermQueryBuilder termQuery(String name, Object value)
name
- The name of the fieldvalue
- The value of the termpublic static FuzzyQueryBuilder fuzzyQuery(String name, String value)
name
- The name of the fieldvalue
- The value of the termpublic static FuzzyQueryBuilder fuzzyQuery(String name, Object value)
name
- The name of the fieldvalue
- The value of the termpublic static PrefixQueryBuilder prefixQuery(String name, String prefix)
name
- The name of the fieldprefix
- The prefix querypublic static RangeQueryBuilder rangeQuery(String name)
name
- The field namepublic static WildcardQueryBuilder wildcardQuery(String name, String query)
name
- The field namequery
- The wildcard query stringpublic static RegexpQueryBuilder regexpQuery(String name, String regexp)
name
- The name of the fieldregexp
- The regular expressionpublic static QueryStringQueryBuilder queryStringQuery(String queryString)
QueryStringQueryBuilder.field(String)
, will run the query once and non prefixed fields
will use the QueryStringQueryBuilder.defaultField(String)
set. The second, when one or more fields are added
(using QueryStringQueryBuilder.field(String)
), will run the parsed query against the provided fields, and combine
them either using DisMax or a plain boolean query (see QueryStringQueryBuilder.useDisMax(boolean)
).queryString
- The query string to runpublic static SimpleQueryStringBuilder simpleQueryStringQuery(String queryString)
SimpleQueryParser
for the full
supported syntax.public static BoostingQueryBuilder boostingQuery()
public static BoolQueryBuilder boolQuery()
public static SpanTermQueryBuilder spanTermQuery(String name, String value)
public static SpanTermQueryBuilder spanTermQuery(String name, int value)
public static SpanTermQueryBuilder spanTermQuery(String name, long value)
public static SpanTermQueryBuilder spanTermQuery(String name, float value)
public static SpanTermQueryBuilder spanTermQuery(String name, double value)
public static SpanFirstQueryBuilder spanFirstQuery(SpanQueryBuilder match, int end)
public static SpanNearQueryBuilder spanNearQuery()
public static SpanNotQueryBuilder spanNotQuery()
public static SpanOrQueryBuilder spanOrQuery()
public static SpanWithinQueryBuilder spanWithinQuery()
span_within
builder.public static SpanContainingQueryBuilder spanContainingQuery()
span_containing
builder.public static SpanMultiTermQueryBuilder spanMultiTermQueryBuilder(MultiTermQueryBuilder multiTermQueryBuilder)
SpanQueryBuilder
which allows having a sub query
which implements MultiTermQueryBuilder
. This is useful for
having e.g. wildcard or fuzzy queries inside spans.multiTermQueryBuilder
- The MultiTermQueryBuilder
that
backs the created builder.public static FieldMaskingSpanQueryBuilder fieldMaskingSpanQuery(SpanQueryBuilder query, String field)
@Deprecated public static FilteredQueryBuilder filteredQuery(@Nullable QueryBuilder queryBuilder, @Nullable QueryBuilder filterBuilder)
boolQuery()
instead with a must
clause
for the query and a filter
clause for the filter.queryBuilder
- The query to apply the filter tofilterBuilder
- The filter to apply on the querypublic static ConstantScoreQueryBuilder constantScoreQuery(QueryBuilder queryBuilder)
queryBuilder
- The query to wrap in a constant score querypublic static FunctionScoreQueryBuilder functionScoreQuery(QueryBuilder queryBuilder)
queryBuilder
- The query to custom scorepublic static FunctionScoreQueryBuilder functionScoreQuery()
public static FunctionScoreQueryBuilder functionScoreQuery(ScoreFunctionBuilder function)
function
- The function builder used to custom scorepublic static FunctionScoreQueryBuilder functionScoreQuery(QueryBuilder queryBuilder, ScoreFunctionBuilder function)
queryBuilder
- The query to custom scorefunction
- The function builder used to custom scorepublic static MoreLikeThisQueryBuilder moreLikeThisQuery(String... fields)
MoreLikeThisQueryBuilder.likeText(String)
which is checked against the fields the query is constructed with.fields
- The fields to run the query againstpublic static MoreLikeThisQueryBuilder moreLikeThisQuery()
MoreLikeThisQueryBuilder.likeText(String)
which is checked against the "_all" field.public static HasChildQueryBuilder hasChildQuery(String type, QueryBuilder query)
type
- The child type.query
- The query.public static HasParentQueryBuilder hasParentQuery(String type, QueryBuilder query)
type
- The parent type.query
- The query.public static NestedQueryBuilder nestedQuery(String path, QueryBuilder query)
public static TermsQueryBuilder termsQuery(String name, String... values)
name
- The field namevalues
- The termspublic static TermsQueryBuilder termsQuery(String name, int... values)
name
- The field namevalues
- The termspublic static TermsQueryBuilder termsQuery(String name, long... values)
name
- The field namevalues
- The termspublic static TermsQueryBuilder termsQuery(String name, float... values)
name
- The field namevalues
- The termspublic static TermsQueryBuilder termsQuery(String name, double... values)
name
- The field namevalues
- The termspublic static TermsQueryBuilder termsQuery(String name, Object... values)
name
- The field namevalues
- The termspublic static TermsQueryBuilder termsQuery(String name, Collection<?> values)
name
- The field namevalues
- The termspublic static IndicesQueryBuilder indicesQuery(QueryBuilder queryBuilder, String... indices)
public static WrapperQueryBuilder wrapperQuery(String source)
public static WrapperQueryBuilder wrapperQuery(BytesReference source)
public static WrapperQueryBuilder wrapperQuery(byte[] source, int offset, int length)
public static GeoShapeQueryBuilder geoShapeQuery(String name, ShapeBuilder shape)
name
- The shape field nameshape
- Shape to use in the Querypublic static TemplateQueryBuilder templateQuery(Template template)
public static TemplateQueryBuilder templateQuery(String template, Map<String,Object> vars)
public static TemplateQueryBuilder templateQuery(String template, ScriptService.ScriptType templateType, Map<String,Object> vars)
public static TypeQueryBuilder typeQuery(String type)
public static TermsLookupQueryBuilder termsLookupQuery(String name)
public static ScriptQueryBuilder scriptQuery(Script script)
script
- The script to filter by.public static GeoDistanceQueryBuilder geoDistanceQuery(String name)
name
- The location field name.public static GeoDistanceRangeQueryBuilder geoDistanceRangeQuery(String name)
name
- The location field name.public static GeoBoundingBoxQueryBuilder geoBoundingBoxQuery(String name)
name
- The location field name.public static GeohashCellQuery.Builder geoHashCellQuery(String name)
{"type":"geo_point", "geohash":true}
to work.name
- The geo point field name.public static GeohashCellQuery.Builder geoHashCellQuery(String name, String geohash)
{"type":"geo_point", "geohash":true}
to work.name
- The geo point field name.geohash
- The Geohash to filterpublic static GeohashCellQuery.Builder geoHashCellQuery(String name, GeoPoint point)
{"type":"geo_point", "geohash":true}
to work.name
- The geo point field name.point
- a geo point within the geohash bucketpublic static GeohashCellQuery.Builder geoHashCellQuery(String name, String geohash, boolean neighbors)
{"type":"geo_point", "geohash":true}
to work.name
- The geo point field namegeohash
- The Geohash to filterneighbors
- should the neighbor cell also be filteredpublic static GeoPolygonQueryBuilder geoPolygonQuery(String name)
name
- The location field name.public static GeoShapeQueryBuilder geoShapeQuery(String name, ShapeBuilder shape, ShapeRelation relation)
name
- The shape field nameshape
- Shape to use in the filterrelation
- relation of the shapespublic static GeoShapeQueryBuilder geoShapeQuery(String name, String indexedShapeId, String indexedShapeType, ShapeRelation relation)
public static GeoShapeQueryBuilder geoShapeQuery(String name, String indexedShapeId, String indexedShapeType)
public static GeoShapeQueryBuilder geoIntersectionQuery(String name, ShapeBuilder shape)
name
- The shape field nameshape
- Shape to use in the filterpublic static GeoShapeQueryBuilder geoIntersectionQuery(String name, String indexedShapeId, String indexedShapeType)
public static GeoShapeQueryBuilder geoWithinQuery(String name, ShapeBuilder shape)
name
- The shape field nameshape
- Shape to use in the filterpublic static GeoShapeQueryBuilder geoWithinQuery(String name, String indexedShapeId, String indexedShapeType)
public static GeoShapeQueryBuilder geoDisjointQuery(String name, ShapeBuilder shape)
name
- The shape field nameshape
- Shape to use in the filterpublic static GeoShapeQueryBuilder geoDisjointQuery(String name, String indexedShapeId, String indexedShapeType)
public static ExistsQueryBuilder existsQuery(String name)
name
- The name of the fieldpublic static MissingQueryBuilder missingQuery(String name)
@Deprecated public static NotQueryBuilder notQuery(QueryBuilder filter)
boolQuery()
and add a mustNot clause instead@Deprecated public static OrQueryBuilder orQuery(QueryBuilder... filters)
boolQuery()
insteadOrQueryBuilder
composed of the given filters.@Deprecated public static AndQueryBuilder andQuery(QueryBuilder... filters)
BoolQueryBuilder.mustNot(QueryBuilder)
insteadAndQueryBuilder
composed of the given filters.@Deprecated public static LimitQueryBuilder limitQuery(int limit)
SearchRequestBuilder.setTerminateAfter(int)
instead@Deprecated public static QueryFilterBuilder queryFilter(QueryBuilder query)
Copyright © 2009–2016. All rights reserved.