org.elasticsearch.index.query
Class FieldQueryBuilder

java.lang.Object
  extended by org.elasticsearch.index.query.BaseQueryBuilder
      extended by org.elasticsearch.index.query.FieldQueryBuilder
All Implemented Interfaces:
ToXContent, BoostableQueryBuilder<FieldQueryBuilder>, QueryBuilder

public class FieldQueryBuilder
extends BaseQueryBuilder
implements BoostableQueryBuilder<FieldQueryBuilder>

A query that executes the query string against a field. It is a simplified version of QueryStringQueryBuilder that simply runs against a single field.


Nested Class Summary
static class FieldQueryBuilder.Operator
           
 
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.MapParams, ToXContent.Params
 
Field Summary
 
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
 
Constructor Summary
FieldQueryBuilder(String name, boolean query)
          A query that executes the query string against a field.
FieldQueryBuilder(String name, double query)
          A query that executes the query string against a field.
FieldQueryBuilder(String name, float query)
          A query that executes the query string against a field.
FieldQueryBuilder(String name, int query)
          A query that executes the query string against a field.
FieldQueryBuilder(String name, long query)
          A query that executes the query string against a field.
FieldQueryBuilder(String name, Object query)
          A query that executes the query string against a field.
FieldQueryBuilder(String name, String query)
          A query that executes the query string against a field.
 
Method Summary
 FieldQueryBuilder allowLeadingWildcard(boolean allowLeadingWildcard)
          Should leading wildcards be allowed or not.
 FieldQueryBuilder analyzer(String analyzer)
          The optional analyzer used to analyze the query string.
 FieldQueryBuilder analyzeWildcard(boolean analyzeWildcard)
          Set to true to enable analysis on wildcard and prefix queries.
 void autoGeneratePhraseQueries(boolean autoGeneratePhraseQueries)
          Set to true if phrase queries will be automatically generated when the analyzer returns more than one term from whitespace delimited text.
 FieldQueryBuilder boost(float boost)
          Sets the boost for this query.
 FieldQueryBuilder defaultOperator(FieldQueryBuilder.Operator defaultOperator)
          Sets the boolean operator of the query parser used to parse the query string.
 void doXContent(XContentBuilder builder, ToXContent.Params params)
           
 FieldQueryBuilder enablePositionIncrements(boolean enablePositionIncrements)
          Set to true to enable position increments in result query.
 FieldQueryBuilder fuzzyMaxExpansions(int fuzzyMaxExpansions)
           
 FieldQueryBuilder fuzzyMinSim(float fuzzyMinSim)
          Set the minimum similarity for fuzzy queries.
 FieldQueryBuilder fuzzyPrefixLength(int fuzzyPrefixLength)
          Set the prefix length for fuzzy queries.
 FieldQueryBuilder fuzzyRewrite(String fuzzyRewrite)
           
 FieldQueryBuilder lowercaseExpandedTerms(boolean lowercaseExpandedTerms)
          Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not.
 FieldQueryBuilder minimumShouldMatch(String minimumShouldMatch)
           
 FieldQueryBuilder phraseSlop(int phraseSlop)
          Sets the default slop for phrases.
 FieldQueryBuilder rewrite(String rewrite)
           
 
Methods inherited from class org.elasticsearch.index.query.BaseQueryBuilder
buildAsBytes, buildAsBytes, toString, toXContent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FieldQueryBuilder

public FieldQueryBuilder(String name,
                         String query)
A query that executes the query string against a field. It is a simplified version of QueryStringQueryBuilder that simply runs against a single field.

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

FieldQueryBuilder

public FieldQueryBuilder(String name,
                         int query)
A query that executes the query string against a field. It is a simplified version of QueryStringQueryBuilder that simply runs against a single field.

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

FieldQueryBuilder

public FieldQueryBuilder(String name,
                         long query)
A query that executes the query string against a field. It is a simplified version of QueryStringQueryBuilder that simply runs against a single field.

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

FieldQueryBuilder

public FieldQueryBuilder(String name,
                         float query)
A query that executes the query string against a field. It is a simplified version of QueryStringQueryBuilder that simply runs against a single field.

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

FieldQueryBuilder

public FieldQueryBuilder(String name,
                         double query)
A query that executes the query string against a field. It is a simplified version of QueryStringQueryBuilder that simply runs against a single field.

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

FieldQueryBuilder

public FieldQueryBuilder(String name,
                         boolean query)
A query that executes the query string against a field. It is a simplified version of QueryStringQueryBuilder that simply runs against a single field.

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

FieldQueryBuilder

public FieldQueryBuilder(String name,
                         Object query)
A query that executes the query string against a field. It is a simplified version of QueryStringQueryBuilder that simply runs against a single field.

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

boost

public FieldQueryBuilder boost(float boost)
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.

Specified by:
boost in interface BoostableQueryBuilder<FieldQueryBuilder>

defaultOperator

public FieldQueryBuilder defaultOperator(FieldQueryBuilder.Operator defaultOperator)
Sets the boolean operator of the query parser used to parse the query string.

In default mode (FieldQueryBuilder.Operator.OR) terms without any modifiers are considered optional: for example capital of Hungary is equal to capital OR of OR Hungary.

In FieldQueryBuilder.Operator.AND mode terms are considered to be in conjunction: the above mentioned query is parsed as capital AND of AND Hungary


analyzer

public FieldQueryBuilder analyzer(String 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.


autoGeneratePhraseQueries

public void autoGeneratePhraseQueries(boolean autoGeneratePhraseQueries)
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.

Set to false if phrase queries should only be generated when surrounded by double quotes.


allowLeadingWildcard

public FieldQueryBuilder allowLeadingWildcard(boolean allowLeadingWildcard)
Should leading wildcards be allowed or not. Defaults to true.


lowercaseExpandedTerms

public FieldQueryBuilder lowercaseExpandedTerms(boolean lowercaseExpandedTerms)
Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not. Default is true.


enablePositionIncrements

public FieldQueryBuilder enablePositionIncrements(boolean enablePositionIncrements)
Set to true to enable position increments in result query. Defaults to true.

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.


fuzzyMinSim

public FieldQueryBuilder fuzzyMinSim(float fuzzyMinSim)
Set the minimum similarity for fuzzy queries. Default is 0.5f.


fuzzyPrefixLength

public FieldQueryBuilder fuzzyPrefixLength(int fuzzyPrefixLength)
Set the prefix length for fuzzy queries. Default is 0.


fuzzyMaxExpansions

public FieldQueryBuilder fuzzyMaxExpansions(int fuzzyMaxExpansions)

fuzzyRewrite

public FieldQueryBuilder fuzzyRewrite(String fuzzyRewrite)

phraseSlop

public FieldQueryBuilder phraseSlop(int phraseSlop)
Sets the default slop for phrases. If zero, then exact phrase matches are required. Default value is zero.


analyzeWildcard

public FieldQueryBuilder analyzeWildcard(boolean analyzeWildcard)
Set to true to enable analysis on wildcard and prefix queries.


rewrite

public FieldQueryBuilder rewrite(String rewrite)

minimumShouldMatch

public FieldQueryBuilder minimumShouldMatch(String minimumShouldMatch)

doXContent

public void doXContent(XContentBuilder builder,
                       ToXContent.Params params)
                throws IOException
Specified by:
doXContent in class BaseQueryBuilder
Throws:
IOException


Copyright © 2009-2012. All Rights Reserved.