org.elasticsearch.action.terms
Class TermsRequest

java.lang.Object
  extended by org.elasticsearch.action.support.broadcast.BroadcastOperationRequest
      extended by org.elasticsearch.action.terms.TermsRequest
All Implemented Interfaces:
ActionRequest, Streamable

public class TermsRequest
extends BroadcastOperationRequest

Terms request represent a request to get terms in one or more indices of specific fields and their document frequencies (in how many document each term exists).

By default, the "_all" field will be used to extract terms and frequencies.

This is very handy to implement things like tag clouds and auto complete (using prefix(String) or regexp(String)).


Nested Class Summary
static class TermsRequest.SortType
          The type of sorting for terms.
 
Field Summary
 
Fields inherited from class org.elasticsearch.action.support.broadcast.BroadcastOperationRequest
indices, queryHint
 
Constructor Summary
TermsRequest(java.lang.String... indices)
          Constructs a new terms requests with the provided indices.
 
Method Summary
 boolean exact()
          Should the doc frequencies be exact frequencies.
 TermsRequest exact(boolean exact)
          Should the doc frequencies be exact frequencies.
 java.lang.String[] fields()
          The fields within each document which terms will be iterated over and returned with the document frequencies.
 TermsRequest fields(java.lang.String... fields)
          The fields within each document which terms will be iterated over and returned with the document frequencies.
 java.lang.String from()
          The lower bound term from which the iteration will start.
 TermsRequest from(java.lang.Object from)
          The lower bound term from which the iteration will start.
 boolean fromInclusive()
          Should the first from (if set using from(Object) be inclusive or not.
 TermsRequest fromInclusive(boolean fromInclusive)
          Should the first from (if set using from(Object) be inclusive or not.
 TermsRequest gt(java.lang.Object from)
          Greater than (like setting from with fromIInclusive set to false).
 TermsRequest gte(java.lang.Object from)
          Greater/equal than (like setting from with fromInclusive set to true).
 TermsRequest lt(java.lang.Object to)
          Lower then (like setting to with toInclusive set to false)
 TermsRequest lte(java.lang.Object to)
          Lower/equal then (like setting to with toInclusive set to false)
 int maxFreq()
          An optional maximum document frequency to filter out terms.
 TermsRequest maxFreq(int maxFreq)
          An optional maximum document frequency to filter out terms.
 int minFreq()
          An optional minimum document frequency to filter out terms.
 TermsRequest minFreq(int minFreq)
          An optional minimum document frequency to filter out terms.
 java.lang.String prefix()
          An optional prefix from which the terms iteration will start (in lex order).
 TermsRequest prefix(java.lang.String prefix)
          An optional prefix from which the terms iteration will start (in lex order).
 void readFrom(StreamInput in)
           
 java.lang.String regexp()
          An optional regular expression to filter out terms (only the ones that match the regexp will return).
 void regexp(java.lang.String regexp)
          An optional regular expression to filter out terms (only the ones that match the regexp will return).
 int size()
          The number of term / doc freq pairs to return per field.
 TermsRequest size(int size)
          The number of term / doc freq pairs to return per field.
 TermsRequest.SortType sortType()
          The type of sorting for term / doc freq.
 TermsRequest sortType(java.lang.String sortType)
          Sets the string representation of the sort type.
 TermsRequest sortType(TermsRequest.SortType sortType)
          The type of sorting for term / doc freq.
 java.lang.String to()
          The upper bound term to which the iteration will end.
 TermsRequest to(java.lang.Object to)
          The upper bound term to which the iteration will end.
 boolean toInclusive()
          Should the last to (if set using to(Object) be inclusive or not.
 TermsRequest toInclusive(boolean toInclusive)
          Should the last to (if set using to(Object) be inclusive or not.
 ActionRequestValidationException validate()
           
 void writeTo(StreamOutput out)
           
 
Methods inherited from class org.elasticsearch.action.support.broadcast.BroadcastOperationRequest
beforeLocalFork, indices, indices, listenerThreaded, listenerThreaded, operationThreading, operationThreading, operationThreading, queryHint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TermsRequest

public TermsRequest(java.lang.String... indices)
Constructs a new terms requests with the provided indices. Don't pass anything for it to run over all the indices.

Method Detail

validate

public ActionRequestValidationException validate()
Specified by:
validate in interface ActionRequest
Overrides:
validate in class BroadcastOperationRequest

fields

public java.lang.String[] fields()
The fields within each document which terms will be iterated over and returned with the document frequencies.


fields

public TermsRequest fields(java.lang.String... fields)
The fields within each document which terms will be iterated over and returned with the document frequencies. By default will use the "_all" field.


from

public java.lang.String from()
The lower bound term from which the iteration will start. Defaults to start from the first.


from

public TermsRequest from(java.lang.Object from)
The lower bound term from which the iteration will start. Defaults to start from the first.


gt

public TermsRequest gt(java.lang.Object from)
Greater than (like setting from with fromIInclusive set to false).


gte

public TermsRequest gte(java.lang.Object from)
Greater/equal than (like setting from with fromInclusive set to true).


lt

public TermsRequest lt(java.lang.Object to)
Lower then (like setting to with toInclusive set to false)


lte

public TermsRequest lte(java.lang.Object to)
Lower/equal then (like setting to with toInclusive set to false)


fromInclusive

public boolean fromInclusive()
Should the first from (if set using from(Object) be inclusive or not. Defaults to false (not inclusive / exclusive).


fromInclusive

public TermsRequest fromInclusive(boolean fromInclusive)
Should the first from (if set using from(Object) be inclusive or not. Defaults to false (not inclusive / exclusive).


to

public java.lang.String to()
The upper bound term to which the iteration will end. Defaults to unbound (null).


to

public TermsRequest to(java.lang.Object to)
The upper bound term to which the iteration will end. Defaults to unbound (null).


toInclusive

public boolean toInclusive()
Should the last to (if set using to(Object) be inclusive or not. Defaults to true.


toInclusive

public TermsRequest toInclusive(boolean toInclusive)
Should the last to (if set using to(Object) be inclusive or not. Defaults to true.


prefix

public java.lang.String prefix()
An optional prefix from which the terms iteration will start (in lex order).


prefix

public TermsRequest prefix(java.lang.String prefix)
An optional prefix from which the terms iteration will start (in lex order).


regexp

public java.lang.String regexp()
An optional regular expression to filter out terms (only the ones that match the regexp will return).


regexp

public void regexp(java.lang.String regexp)
An optional regular expression to filter out terms (only the ones that match the regexp will return).


minFreq

public int minFreq()
An optional minimum document frequency to filter out terms.


minFreq

public TermsRequest minFreq(int minFreq)
An optional minimum document frequency to filter out terms.


maxFreq

public int maxFreq()
An optional maximum document frequency to filter out terms.


maxFreq

public TermsRequest maxFreq(int maxFreq)
An optional maximum document frequency to filter out terms.


size

public int size()
The number of term / doc freq pairs to return per field. Defaults to 10.


size

public TermsRequest size(int size)
The number of term / doc freq pairs to return per field. Defaults to 10.


sortType

public TermsRequest.SortType sortType()
The type of sorting for term / doc freq. Can either sort on term (lex) or doc frequency. Defaults to TermsRequest.SortType.TERM.


sortType

public TermsRequest sortType(TermsRequest.SortType sortType)
The type of sorting for term / doc freq. Can either sort on term (lex) or doc frequency. Defaults to TermsRequest.SortType.TERM.


sortType

public TermsRequest sortType(java.lang.String sortType)
Sets the string representation of the sort type.


exact

public boolean exact()
Should the doc frequencies be exact frequencies. Exact frequencies takes into account deletes that have not been merged and cleaned (optimized). Note, when this is set to true this operation might be an expensive operation. Defaults to false.


exact

public TermsRequest exact(boolean exact)
Should the doc frequencies be exact frequencies. Exact frequencies takes into account deletes that have not been merged and cleaned (optimized). Note, when this is set to true this operation might be an expensive operation. Defaults to false.


writeTo

public void writeTo(StreamOutput out)
             throws java.io.IOException
Specified by:
writeTo in interface Streamable
Overrides:
writeTo in class BroadcastOperationRequest
Throws:
java.io.IOException

readFrom

public void readFrom(StreamInput in)
              throws java.io.IOException
Specified by:
readFrom in interface Streamable
Overrides:
readFrom in class BroadcastOperationRequest
Throws:
java.io.IOException