org.elasticsearch.action.count
Class CountRequest

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

public class CountRequest
extends BroadcastOperationRequest

A request to count the number of documents matching a specific query. Best created with Requests.countRequest(String...).

The request requires the query source to be set either using query(org.elasticsearch.index.query.QueryBuilder), or query(byte[]).

See Also:
CountResponse, Client.count(CountRequest), Requests.countRequest(String...)

Field Summary
static float DEFAULT_MIN_SCORE
           
 
Fields inherited from class org.elasticsearch.action.support.broadcast.BroadcastOperationRequest
indices, queryHint
 
Constructor Summary
CountRequest(java.lang.String... indices)
          Constructs a new count request against the provided indices.
 
Method Summary
protected  void beforeLocalFork()
           
 CountRequest indices(java.lang.String... indices)
           
 CountRequest listenerThreaded(boolean threadedListener)
          Should the listener be called on a separate thread if needed.
 CountRequest minScore(float minScore)
          The minimum score of the documents to include in the count.
 CountRequest operationThreading(BroadcastOperationThreading operationThreading)
          Controls the operation threading model.
 CountRequest query(byte[] querySource)
          The query source to execute.
 CountRequest query(byte[] querySource, int offset, int length)
          The query source to execute.
 CountRequest query(java.util.Map querySource)
          The query source to execute in the form of a map.
 CountRequest query(QueryBuilder queryBuilder)
          The query source to execute.
 CountRequest query(java.lang.String querySource)
          The query source to execute.
 CountRequest query(XContentBuilder builder)
           
 CountRequest queryHint(java.lang.String queryHint)
          A query hint to optionally later be used when routing the request.
 CountRequest queryParserName(java.lang.String queryParserName)
          The query parse name to use.
 void readFrom(StreamInput in)
           
 java.lang.String toString()
           
 CountRequest types(java.lang.String... types)
          The types of documents the query will run against.
 ActionRequestValidationException validate()
           
 void writeTo(StreamOutput out)
           
 
Methods inherited from class org.elasticsearch.action.support.broadcast.BroadcastOperationRequest
indices, listenerThreaded, operationThreading, operationThreading, queryHint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MIN_SCORE

public static final float DEFAULT_MIN_SCORE
See Also:
Constant Field Values
Constructor Detail

CountRequest

public CountRequest(java.lang.String... indices)
Constructs a new count request against the provided indices. No indices provided means it will run against all indices.

Method Detail

validate

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

operationThreading

public CountRequest operationThreading(BroadcastOperationThreading operationThreading)
Controls the operation threading model.

Overrides:
operationThreading in class BroadcastOperationRequest

beforeLocalFork

protected void beforeLocalFork()
Overrides:
beforeLocalFork in class BroadcastOperationRequest

listenerThreaded

public CountRequest listenerThreaded(boolean threadedListener)
Should the listener be called on a separate thread if needed.

Specified by:
listenerThreaded in interface ActionRequest
Overrides:
listenerThreaded in class BroadcastOperationRequest

indices

public CountRequest indices(java.lang.String... indices)
Overrides:
indices in class BroadcastOperationRequest

queryHint

public CountRequest queryHint(java.lang.String queryHint)
A query hint to optionally later be used when routing the request.


minScore

public CountRequest minScore(float minScore)
The minimum score of the documents to include in the count. Defaults to -1 which means all documents will be included in the count.


query

@Required
public CountRequest query(QueryBuilder queryBuilder)
The query source to execute.

See Also:
QueryBuilders

query

@Required
public CountRequest query(java.util.Map querySource)
The query source to execute in the form of a map.


query

@Required
public CountRequest query(XContentBuilder builder)

query

@Required
public CountRequest query(java.lang.String querySource)
The query source to execute. It is preferable to use either query(byte[]) or query(org.elasticsearch.index.query.QueryBuilder).


query

@Required
public CountRequest query(byte[] querySource)
The query source to execute.


query

@Required
public CountRequest query(byte[] querySource,
                                   int offset,
                                   int length)
The query source to execute.


queryParserName

public CountRequest queryParserName(java.lang.String queryParserName)
The query parse name to use. If not set, will use the default one.


types

public CountRequest types(java.lang.String... types)
The types of documents the query will run against. Defaults to all types.


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

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object