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
           
protected  String queryHint
           
protected  String routing
           
 
Fields inherited from class org.elasticsearch.action.support.broadcast.BroadcastOperationRequest
indices
 
Constructor Summary
CountRequest(String... indices)
          Constructs a new count request against the provided indices.
 
Method Summary
protected  void beforeStart()
           
 CountRequest indices(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, boolean unsafe)
          The query source to execute.
 CountRequest query(BytesReference querySource, boolean unsafe)
           
 CountRequest query(Map querySource)
          The query source to execute in the form of a map.
 CountRequest query(QueryBuilder queryBuilder)
          The query source to execute.
 CountRequest query(String querySource)
          The query source to execute.
 CountRequest query(XContentBuilder builder)
           
 String queryHint()
           
 CountRequest queryHint(String queryHint)
          A query hint to optionally later be used when routing the request.
 void readFrom(StreamInput in)
           
 String routing()
          A comma separated list of routing values to control the shards the search will be executed on.
 CountRequest routing(String... routings)
          The routing values to control the shards that the search will be executed on.
 CountRequest routing(String routing)
          A comma separated list of routing values to control the shards the search will be executed on.
 String toString()
           
 CountRequest types(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
beforeLocalFork, ignoreIndices, ignoreIndices, indices, listenerThreaded, operationThreading, operationThreading
 
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

queryHint

@Nullable
protected String queryHint

routing

@Nullable
protected String routing
Constructor Detail

CountRequest

public CountRequest(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

queryHint

public String queryHint()

operationThreading

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

Overrides:
operationThreading in class BroadcastOperationRequest

beforeStart

protected void beforeStart()
Overrides:
beforeStart 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(String... indices)
Overrides:
indices in class BroadcastOperationRequest

queryHint

public CountRequest queryHint(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(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(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,
                                   boolean unsafe)
The query source to execute.


query

@Required
public CountRequest query(BytesReference querySource,
                                   boolean unsafe)

types

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


routing

public String routing()
A comma separated list of routing values to control the shards the search will be executed on.


routing

public CountRequest routing(String routing)
A comma separated list of routing values to control the shards the search will be executed on.


routing

public CountRequest routing(String... routings)
The routing values to control the shards that the search will be executed on.


readFrom

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

writeTo

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

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009-2012. All Rights Reserved.