org.elasticsearch.index.query.json
Class JsonQueryBuilders

java.lang.Object
  extended by org.elasticsearch.index.query.json.JsonQueryBuilders

public abstract class JsonQueryBuilders
extends java.lang.Object

A static factory for simple "import static" usage.


Method Summary
static BoolJsonQueryBuilder boolQuery()
          A Query that matches documents matching boolean combinations of other queries.
static ConstantScoreQueryJsonQueryBuilder constantScoreQuery(JsonFilterBuilder filterBuilder)
          A query that wraps a filter and simply returns a constant score equal to the query boost for every document in the filter.
static DisMaxJsonQueryBuilder 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 FieldJsonQueryBuilder fieldQuery(java.lang.String name, double query)
          A query that executes the query string against a field.
static FieldJsonQueryBuilder fieldQuery(java.lang.String name, float query)
          A query that executes the query string against a field.
static FieldJsonQueryBuilder fieldQuery(java.lang.String name, int query)
          A query that executes the query string against a field.
static FieldJsonQueryBuilder fieldQuery(java.lang.String name, long query)
          A query that executes the query string against a field.
static FieldJsonQueryBuilder fieldQuery(java.lang.String name, java.lang.String query)
          A query that executes the query string against a field.
static FilteredJsonQueryBuilder filtered(JsonQueryBuilder queryBuilder, JsonFilterBuilder filterBuilder)
          A query that applies a filter to the results of another query.
static FuzzyLikeThisFieldJsonQueryBuilder fuzzyLikeThisFieldQuery(java.lang.String name)
          A fuzzy like this query that finds documents that are "like" the provided FuzzyLikeThisFieldJsonQueryBuilder.likeText(String).
static FuzzyLikeThisJsonQueryBuilder fuzzyLikeThisQuery()
          A fuzzy like this query that finds documents that are "like" the provided FuzzyLikeThisJsonQueryBuilder.likeText(String) which is checked against the "_all" field.
static FuzzyLikeThisJsonQueryBuilder fuzzyLikeThisQuery(java.lang.String... fields)
          A fuzzy like this query that finds documents that are "like" the provided FuzzyLikeThisJsonQueryBuilder.likeText(String) which is checked against the fields the query is constructed with.
static MatchAllJsonQueryBuilder matchAllQuery()
          A query that match on all documents.
static MoreLikeThisFieldJsonQueryBuilder moreLikeThisFieldQuery(java.lang.String name)
          A more like this query that runs against a specific field.
static MoreLikeThisJsonQueryBuilder moreLikeThisQuery()
          A more like this query that finds documents that are "like" the provided MoreLikeThisJsonQueryBuilder.likeText(String) which is checked against the "_all" field.
static MoreLikeThisJsonQueryBuilder moreLikeThisQuery(java.lang.String... fields)
          A more like this query that finds documents that are "like" the provided MoreLikeThisJsonQueryBuilder.likeText(String) which is checked against the fields the query is constructed with.
static PrefixJsonQueryBuilder prefixQuery(java.lang.String name, java.lang.String prefix)
          A Query that matches documents containing terms with a specified prefix.
static QueryStringJsonQueryBuilder queryString(java.lang.String queryString)
          A query that parses a query string and runs it.
static RangeJsonQueryBuilder rangeQuery(java.lang.String name)
          A Query that matches documents within an range of terms.
static SpanFirstJsonQueryBuilder spanFirstQuery(JsonSpanQueryBuilder match, int end)
           
static SpanNearJsonQueryBuilder spanNearQuery()
           
static SpanNotJsonQueryBuilder spanNotQuery()
           
static SpanOrJsonQueryBuilder spanOrQuery()
           
static SpanTermJsonQueryBuilder spanTermQuery(java.lang.String name, double value)
           
static SpanTermJsonQueryBuilder spanTermQuery(java.lang.String name, float value)
           
static SpanTermJsonQueryBuilder spanTermQuery(java.lang.String name, int value)
           
static SpanTermJsonQueryBuilder spanTermQuery(java.lang.String name, long value)
           
static SpanTermJsonQueryBuilder spanTermQuery(java.lang.String name, java.lang.String value)
           
static TermJsonQueryBuilder termQuery(java.lang.String name, double value)
          A Query that matches documents containing a term.
static TermJsonQueryBuilder termQuery(java.lang.String name, float value)
          A Query that matches documents containing a term.
static TermJsonQueryBuilder termQuery(java.lang.String name, int value)
          A Query that matches documents containing a term.
static TermJsonQueryBuilder termQuery(java.lang.String name, long value)
          A Query that matches documents containing a term.
static TermJsonQueryBuilder termQuery(java.lang.String name, java.lang.String value)
          A Query that matches documents containing a term.
static WildcardJsonQueryBuilder wildcardQuery(java.lang.String name, java.lang.String query)
          Implements the wildcard search query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

matchAllQuery

public static MatchAllJsonQueryBuilder matchAllQuery()
A query that match on all documents.


disMaxQuery

public static DisMaxJsonQueryBuilder 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.


termQuery

public static TermJsonQueryBuilder termQuery(java.lang.String name,
                                             java.lang.String value)
A Query that matches documents containing a term.

Parameters:
name - The name of the field
value - The value of the term

termQuery

public static TermJsonQueryBuilder termQuery(java.lang.String name,
                                             int value)
A Query that matches documents containing a term.

Parameters:
name - The name of the field
value - The value of the term

termQuery

public static TermJsonQueryBuilder termQuery(java.lang.String name,
                                             long value)
A Query that matches documents containing a term.

Parameters:
name - The name of the field
value - The value of the term

termQuery

public static TermJsonQueryBuilder termQuery(java.lang.String name,
                                             float value)
A Query that matches documents containing a term.

Parameters:
name - The name of the field
value - The value of the term

termQuery

public static TermJsonQueryBuilder termQuery(java.lang.String name,
                                             double value)
A Query that matches documents containing a term.

Parameters:
name - The name of the field
value - The value of the term

fieldQuery

public static FieldJsonQueryBuilder fieldQuery(java.lang.String name,
                                               java.lang.String query)
A query that executes the query string against a field. It is a simplified version of QueryStringJsonQueryBuilder that simply runs against a single field.

Parameters:
name - The name of the field

fieldQuery

public static FieldJsonQueryBuilder fieldQuery(java.lang.String name,
                                               int query)
A query that executes the query string against a field. It is a simplified version of QueryStringJsonQueryBuilder that simply runs against a single field.

Parameters:
name - The name of the field
query - The query string

fieldQuery

public static FieldJsonQueryBuilder fieldQuery(java.lang.String name,
                                               long query)
A query that executes the query string against a field. It is a simplified version of QueryStringJsonQueryBuilder that simply runs against a single field.

Parameters:
name - The name of the field
query - The query string

fieldQuery

public static FieldJsonQueryBuilder fieldQuery(java.lang.String name,
                                               float query)
A query that executes the query string against a field. It is a simplified version of QueryStringJsonQueryBuilder that simply runs against a single field.

Parameters:
name - The name of the field
query - The query string

fieldQuery

public static FieldJsonQueryBuilder fieldQuery(java.lang.String name,
                                               double query)
A query that executes the query string against a field. It is a simplified version of QueryStringJsonQueryBuilder that simply runs against a single field.

Parameters:
name - The name of the field
query - The query string

prefixQuery

public static PrefixJsonQueryBuilder prefixQuery(java.lang.String name,
                                                 java.lang.String prefix)
A Query that matches documents containing terms with a specified prefix.

Parameters:
name - The name of the field
prefix - The prefix query

rangeQuery

public static RangeJsonQueryBuilder rangeQuery(java.lang.String name)
A Query that matches documents within an range of terms.

Parameters:
name - The field name

wildcardQuery

public static WildcardJsonQueryBuilder wildcardQuery(java.lang.String name,
                                                     java.lang.String query)
Implements the wildcard search query. Supported wildcards are *, which matches any character sequence (including the empty one), and ?, which matches any single character. Note this query can be slow, as it needs to iterate over many terms. In order to prevent extremely slow WildcardQueries, a Wildcard term should not start with one of the wildcards * or ?.

Parameters:
name - The field name
query - The wildcard query string

queryString

public static QueryStringJsonQueryBuilder queryString(java.lang.String queryString)
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 QueryStringJsonQueryBuilder.field(String), will run the query once and non prefixed fields will use the QueryStringJsonQueryBuilder.defaultField(String) set. The second, when one or more fields are added (using QueryStringJsonQueryBuilder.field(String)), will run the parsed query against the provided fields, and combine them either using DisMax or a plain boolean query (see QueryStringJsonQueryBuilder.useDisMax(boolean)).

Parameters:
queryString - The query string to run

boolQuery

public static BoolJsonQueryBuilder boolQuery()
A Query that matches documents matching boolean combinations of other queries.


spanTermQuery

public static SpanTermJsonQueryBuilder spanTermQuery(java.lang.String name,
                                                     java.lang.String value)

spanTermQuery

public static SpanTermJsonQueryBuilder spanTermQuery(java.lang.String name,
                                                     int value)

spanTermQuery

public static SpanTermJsonQueryBuilder spanTermQuery(java.lang.String name,
                                                     long value)

spanTermQuery

public static SpanTermJsonQueryBuilder spanTermQuery(java.lang.String name,
                                                     float value)

spanTermQuery

public static SpanTermJsonQueryBuilder spanTermQuery(java.lang.String name,
                                                     double value)

spanFirstQuery

public static SpanFirstJsonQueryBuilder spanFirstQuery(JsonSpanQueryBuilder match,
                                                       int end)

spanNearQuery

public static SpanNearJsonQueryBuilder spanNearQuery()

spanNotQuery

public static SpanNotJsonQueryBuilder spanNotQuery()

spanOrQuery

public static SpanOrJsonQueryBuilder spanOrQuery()

filtered

public static FilteredJsonQueryBuilder filtered(JsonQueryBuilder queryBuilder,
                                                JsonFilterBuilder filterBuilder)
A query that applies a filter to the results of another query.

Parameters:
queryBuilder - The query to apply the filter to
filterBuilder - The filter to apply on the query

constantScoreQuery

public static ConstantScoreQueryJsonQueryBuilder constantScoreQuery(JsonFilterBuilder filterBuilder)
A query that wraps a filter and simply returns a constant score equal to the query boost for every document in the filter.

Parameters:
filterBuilder - The filter to wrap in a constant score query

moreLikeThisQuery

public static MoreLikeThisJsonQueryBuilder moreLikeThisQuery(java.lang.String... fields)
A more like this query that finds documents that are "like" the provided MoreLikeThisJsonQueryBuilder.likeText(String) which is checked against the fields the query is constructed with.

Parameters:
fields - The fields to run the query against

moreLikeThisQuery

public static MoreLikeThisJsonQueryBuilder moreLikeThisQuery()
A more like this query that finds documents that are "like" the provided MoreLikeThisJsonQueryBuilder.likeText(String) which is checked against the "_all" field.


fuzzyLikeThisQuery

public static FuzzyLikeThisJsonQueryBuilder fuzzyLikeThisQuery(java.lang.String... fields)
A fuzzy like this query that finds documents that are "like" the provided FuzzyLikeThisJsonQueryBuilder.likeText(String) which is checked against the fields the query is constructed with.

Parameters:
fields - The fields to run the query against

fuzzyLikeThisQuery

public static FuzzyLikeThisJsonQueryBuilder fuzzyLikeThisQuery()
A fuzzy like this query that finds documents that are "like" the provided FuzzyLikeThisJsonQueryBuilder.likeText(String) which is checked against the "_all" field.


fuzzyLikeThisFieldQuery

public static FuzzyLikeThisFieldJsonQueryBuilder fuzzyLikeThisFieldQuery(java.lang.String name)
A fuzzy like this query that finds documents that are "like" the provided FuzzyLikeThisFieldJsonQueryBuilder.likeText(String).


moreLikeThisFieldQuery

public static MoreLikeThisFieldJsonQueryBuilder moreLikeThisFieldQuery(java.lang.String name)
A more like this query that runs against a specific field.

Parameters:
name - The field name