org.elasticsearch.index.query
Class MatchQueryBuilder

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

public class MatchQueryBuilder
extends BaseQueryBuilder
implements BoostableQueryBuilder<MatchQueryBuilder>

Match query is a query that analyzes the text and constructs a query as the result of the analysis. It can construct different queries based on the type provided.


Nested Class Summary
static class MatchQueryBuilder.Operator
           
static class MatchQueryBuilder.Type
           
 
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
MatchQueryBuilder(String name, Object text)
          Constructs a new text query.
 
Method Summary
 MatchQueryBuilder analyzer(String analyzer)
          Explicitly set the analyzer to use.
 MatchQueryBuilder boost(float boost)
          Set the boost to apply to the query.
 void doXContent(XContentBuilder builder, ToXContent.Params params)
           
 MatchQueryBuilder fuzziness(Object fuzziness)
          Sets the minimum similarity used when evaluated to a fuzzy query type.
 MatchQueryBuilder fuzzyRewrite(String fuzzyRewrite)
           
 MatchQueryBuilder maxExpansions(int maxExpansions)
          When using fuzzy or prefix type query, the number of term expansions to use.
 MatchQueryBuilder minimumShouldMatch(String minimumShouldMatch)
           
 MatchQueryBuilder operator(MatchQueryBuilder.Operator operator)
          Sets the operator to use when using a boolean query.
 MatchQueryBuilder prefixLength(int prefixLength)
           
 MatchQueryBuilder rewrite(String rewrite)
           
 MatchQueryBuilder setLenient(boolean lenient)
          Sets whether format based failures will be ignored.
 MatchQueryBuilder slop(int slop)
          Set the phrase slop if evaluated to a phrase query type.
 MatchQueryBuilder type(MatchQueryBuilder.Type type)
          Sets the type of the text query.
 
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

MatchQueryBuilder

public MatchQueryBuilder(String name,
                         Object text)
Constructs a new text query.

Method Detail

type

public MatchQueryBuilder type(MatchQueryBuilder.Type type)
Sets the type of the text query.


operator

public MatchQueryBuilder operator(MatchQueryBuilder.Operator operator)
Sets the operator to use when using a boolean query. Defaults to OR.


analyzer

public MatchQueryBuilder analyzer(String analyzer)
Explicitly set the analyzer to use. Defaults to use explicit mapping config for the field, or, if not set, the default search analyzer.


boost

public MatchQueryBuilder boost(float boost)
Set the boost to apply to the query.

Specified by:
boost in interface BoostableQueryBuilder<MatchQueryBuilder>

slop

public MatchQueryBuilder slop(int slop)
Set the phrase slop if evaluated to a phrase query type.


fuzziness

public MatchQueryBuilder fuzziness(Object fuzziness)
Sets the minimum similarity used when evaluated to a fuzzy query type. Defaults to "0.5".


prefixLength

public MatchQueryBuilder prefixLength(int prefixLength)

maxExpansions

public MatchQueryBuilder maxExpansions(int maxExpansions)
When using fuzzy or prefix type query, the number of term expansions to use. Defaults to unbounded so its recommended to set it to a reasonable value for faster execution.


minimumShouldMatch

public MatchQueryBuilder minimumShouldMatch(String minimumShouldMatch)

rewrite

public MatchQueryBuilder rewrite(String rewrite)

fuzzyRewrite

public MatchQueryBuilder fuzzyRewrite(String fuzzyRewrite)

setLenient

public MatchQueryBuilder setLenient(boolean lenient)
Sets whether format based failures will be ignored.


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.