org.elasticsearch.search.facet.terms
Class TermsFacetBuilder

java.lang.Object
  extended by org.elasticsearch.search.facet.AbstractFacetBuilder
      extended by org.elasticsearch.search.facet.terms.TermsFacetBuilder
All Implemented Interfaces:
ToXContent

public class TermsFacetBuilder
extends AbstractFacetBuilder

Term facets allow to collect frequency of terms within one (or more) field.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.MapParams, ToXContent.Params
 
Field Summary
 
Fields inherited from class org.elasticsearch.search.facet.AbstractFacetBuilder
facetFilter, global, name
 
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
 
Constructor Summary
TermsFacetBuilder(java.lang.String name)
          Construct a new term facet with the provided facet name.
 
Method Summary
 TermsFacetBuilder exclude(java.lang.String... exclude)
          A set of terms that will be excluded.
 TermsFacetBuilder facetFilter(XContentFilterBuilder filter)
          An additional facet filter that will further filter the documents the facet will be executed on.
 TermsFacetBuilder field(java.lang.String field)
          The field the terms will be collected from.
 TermsFacetBuilder fields(java.lang.String... fields)
          The fields the terms will be collected from.
 TermsFacetBuilder global(boolean global)
          Should the fact run in global mode (not bounded by the search query) or not.
 TermsFacetBuilder lang(java.lang.String lang)
          The language of the script.
 TermsFacetBuilder order(TermsFacet.ComparatorType comparatorType)
          The order by which to return the facets by.
 TermsFacetBuilder param(java.lang.String name, java.lang.Object value)
          A parameter that will be passed to the script.
 TermsFacetBuilder regex(java.lang.String regex)
          A regular expression to use in order to further filter terms.
 TermsFacetBuilder regex(java.lang.String regex, int flags)
          A regular expression (with flags) to use in order to further filter terms.
 TermsFacetBuilder script(java.lang.String script)
          A script allowing to either modify or ignore a provided term (can be accessed using term var).
 TermsFacetBuilder scriptField(java.lang.String scriptField)
          Define a script field that will control the terms that will be used (and not filtered, as is the case when the script is provided on top of field / fields).
 TermsFacetBuilder size(int size)
          The number of terms (and frequencies) to return.
 void toXContent(XContentBuilder builder, ToXContent.Params params)
           
 
Methods inherited from class org.elasticsearch.search.facet.AbstractFacetBuilder
addFilterFacetAndGlobal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TermsFacetBuilder

public TermsFacetBuilder(java.lang.String name)
Construct a new term facet with the provided facet name.

Parameters:
name - The facet name.
Method Detail

global

public TermsFacetBuilder global(boolean global)
Should the fact run in global mode (not bounded by the search query) or not. Defaults to false.

Overrides:
global in class AbstractFacetBuilder

facetFilter

public TermsFacetBuilder facetFilter(XContentFilterBuilder filter)
An additional facet filter that will further filter the documents the facet will be executed on.

Overrides:
facetFilter in class AbstractFacetBuilder

field

public TermsFacetBuilder field(java.lang.String field)
The field the terms will be collected from.


fields

public TermsFacetBuilder fields(java.lang.String... fields)
The fields the terms will be collected from.


scriptField

public TermsFacetBuilder scriptField(java.lang.String scriptField)
Define a script field that will control the terms that will be used (and not filtered, as is the case when the script is provided on top of field / fields).


exclude

public TermsFacetBuilder exclude(java.lang.String... exclude)
A set of terms that will be excluded.


size

public TermsFacetBuilder size(int size)
The number of terms (and frequencies) to return. Defaults to 10.


regex

public TermsFacetBuilder regex(java.lang.String regex)
A regular expression to use in order to further filter terms.


regex

public TermsFacetBuilder regex(java.lang.String regex,
                               int flags)
A regular expression (with flags) to use in order to further filter terms.


order

public TermsFacetBuilder order(TermsFacet.ComparatorType comparatorType)
The order by which to return the facets by. Defaults to TermsFacet.ComparatorType.COUNT.


script

public TermsFacetBuilder script(java.lang.String script)
A script allowing to either modify or ignore a provided term (can be accessed using term var).


lang

public TermsFacetBuilder lang(java.lang.String lang)
The language of the script.


param

public TermsFacetBuilder param(java.lang.String name,
                               java.lang.Object value)
A parameter that will be passed to the script.

Parameters:
name - The name of the script parameter.
value - The value of the script parameter.

toXContent

public void toXContent(XContentBuilder builder,
                       ToXContent.Params params)
                throws java.io.IOException
Throws:
java.io.IOException