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, name, nested, scope
 
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
 
Constructor Summary
TermsFacetBuilder(String name)
          Construct a new term facet with the provided facet name.
 
Method Summary
 TermsFacetBuilder allTerms(boolean allTerms)
          Sets all possible terms to be loaded, even ones with 0 count.
 TermsFacetBuilder exclude(Object... exclude)
          A set of terms that will be excluded.
 TermsFacetBuilder executionHint(String executionHint)
          An execution hint to how the facet is computed.
 TermsFacetBuilder facetFilter(FilterBuilder filter)
          An additional facet filter that will further filter the documents the facet will be executed on.
 TermsFacetBuilder field(String field)
          The field the terms will be collected from.
 TermsFacetBuilder fields(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(String lang)
          The language of the script.
 TermsFacetBuilder nested(String nested)
          Sets the nested path the facet will execute on.
 TermsFacetBuilder order(TermsFacet.ComparatorType comparatorType)
          The order by which to return the facets by.
 TermsFacetBuilder param(String name, Object value)
          A parameter that will be passed to the script.
 TermsFacetBuilder regex(String regex)
          A regular expression to use in order to further filter terms.
 TermsFacetBuilder regex(String regex, int flags)
          A regular expression (with flags) to use in order to further filter terms.
 TermsFacetBuilder scope(String scope)
          Marks the facet to run in a specific scope.
 TermsFacetBuilder script(String script)
          A script allowing to either modify or ignore a provided term (can be accessed using term var).
 TermsFacetBuilder scriptField(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.
 XContentBuilder 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(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

scope

public TermsFacetBuilder scope(String scope)
Marks the facet to run in a specific scope.

Overrides:
scope in class AbstractFacetBuilder

facetFilter

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

Overrides:
facetFilter in class AbstractFacetBuilder

nested

public TermsFacetBuilder nested(String nested)
Sets the nested path the facet will execute on. A match (root object) will then cause all the nested objects matching the path to be computed into the facet.

Overrides:
nested in class AbstractFacetBuilder

field

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


fields

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


scriptField

public TermsFacetBuilder scriptField(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(Object... 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(String regex)
A regular expression to use in order to further filter terms.


regex

public TermsFacetBuilder regex(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(String script)
A script allowing to either modify or ignore a provided term (can be accessed using term var).


lang

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


executionHint

public TermsFacetBuilder executionHint(String executionHint)
An execution hint to how the facet is computed.


param

public TermsFacetBuilder param(String name,
                               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.

allTerms

public TermsFacetBuilder allTerms(boolean allTerms)
Sets all possible terms to be loaded, even ones with 0 count. Note, this *should not* be used with a field that has many possible terms.


toXContent

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


Copyright © 2009-2012. All Rights Reserved.