Class CountRequest

java.lang.Object
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.TransportRequest
org.elasticsearch.action.ActionRequest
org.elasticsearch.client.core.CountRequest
All Implemented Interfaces:
org.elasticsearch.action.IndicesRequest, org.elasticsearch.action.IndicesRequest.Replaceable, org.elasticsearch.common.io.stream.Writeable, org.elasticsearch.core.RefCounted, org.elasticsearch.tasks.TaskAwareRequest, org.elasticsearch.xcontent.ToXContent, org.elasticsearch.xcontent.ToXContentObject

public final class CountRequest extends org.elasticsearch.action.ActionRequest implements org.elasticsearch.action.IndicesRequest.Replaceable, org.elasticsearch.xcontent.ToXContentObject
Encapsulates a request to _count API against one, several or all indices.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.elasticsearch.transport.TransportRequest

    org.elasticsearch.transport.TransportRequest.Empty

    Nested classes/interfaces inherited from interface org.elasticsearch.action.IndicesRequest

    org.elasticsearch.action.IndicesRequest.Replaceable

    Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent

    org.elasticsearch.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.xcontent.ToXContent.MapParams, org.elasticsearch.xcontent.ToXContent.Params

    Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable

    org.elasticsearch.common.io.stream.Writeable.Reader<V extends Object>, org.elasticsearch.common.io.stream.Writeable.Writer<V extends Object>
  • Field Summary

    Fields inherited from interface org.elasticsearch.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    CountRequest(String... indices)
    Constructs a new count request against the indices.
    CountRequest(String[] indices, org.elasticsearch.index.query.QueryBuilder query)
    Constructs a new search request against the provided indices with the given query.
    CountRequest(String[] indices, org.elasticsearch.search.builder.SearchSourceBuilder searchSourceBuilder)
    Deprecated.
    The count api only supports a query.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    int
     
     
    indices(String... indices)
    Sets the indices the count will be executed on.
    org.elasticsearch.action.support.IndicesOptions
     
    indicesOptions(org.elasticsearch.action.support.IndicesOptions indicesOptions)
    Returns the indices options used to resolve indices.
     
    minScore(Float minScore)
     
     
    preference(String preference)
    Sets the preference to execute the count.
    org.elasticsearch.index.query.QueryBuilder
     
    query(org.elasticsearch.index.query.QueryBuilder query)
    Sets the query to execute for this count request.
     
    routing(String routing)
    The routing values to control the shards that the search will be executed on.
    routing(String... routings)
    A comma separated list of routing values to control the shards the count will be executed on.
    org.elasticsearch.search.builder.SearchSourceBuilder
    Deprecated.
    The count api only supports a query.
    source(org.elasticsearch.search.builder.SearchSourceBuilder searchSourceBuilder)
    Deprecated.
    The count api only supports a query.
    int
     
    terminateAfter(int terminateAfter)
     
    org.elasticsearch.xcontent.XContentBuilder
    toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params)
     
    Deprecated.
    Types are in the process of being removed.
    types(String... types)
    Deprecated.
    Types are in the process of being removed.
    org.elasticsearch.action.ActionRequestValidationException
     

    Methods inherited from class org.elasticsearch.action.ActionRequest

    getShouldStoreResult, writeTo

    Methods inherited from class org.elasticsearch.transport.TransportRequest

    getParentTask, setParentTask, toString

    Methods inherited from class org.elasticsearch.transport.TransportMessage

    decRef, hasReferences, incRef, remoteAddress, remoteAddress, tryIncRef

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.elasticsearch.action.IndicesRequest

    includeDataStreams

    Methods inherited from interface org.elasticsearch.action.IndicesRequest.Replaceable

    allowsRemoteIndices

    Methods inherited from interface org.elasticsearch.tasks.TaskAwareRequest

    createTask, getDescription, setParentTask

    Methods inherited from interface org.elasticsearch.xcontent.ToXContentObject

    isFragment
  • Constructor Details

    • CountRequest

      public CountRequest()
    • CountRequest

      public CountRequest(String... indices)
      Constructs a new count request against the indices. No indices provided here means that count will execute on all indices.
    • CountRequest

      @Deprecated public CountRequest(String[] indices, org.elasticsearch.search.builder.SearchSourceBuilder searchSourceBuilder)
      Deprecated.
      The count api only supports a query. Use CountRequest(String[], QueryBuilder) instead.
      Constructs a new search request against the provided indices with the given search source.
    • CountRequest

      public CountRequest(String[] indices, org.elasticsearch.index.query.QueryBuilder query)
      Constructs a new search request against the provided indices with the given query.
  • Method Details

    • validate

      public org.elasticsearch.action.ActionRequestValidationException validate()
      Specified by:
      validate in class org.elasticsearch.action.ActionRequest
    • indices

      public CountRequest indices(String... indices)
      Sets the indices the count will be executed on.
      Specified by:
      indices in interface org.elasticsearch.action.IndicesRequest.Replaceable
    • source

      @Deprecated public CountRequest source(org.elasticsearch.search.builder.SearchSourceBuilder searchSourceBuilder)
      Deprecated.
      The count api only supports a query. Use query(QueryBuilder) instead.
      The source of the count request.
    • query

      public CountRequest query(org.elasticsearch.index.query.QueryBuilder query)
      Sets the query to execute for this count request.
    • types

      @Deprecated public CountRequest types(String... types)
      Deprecated.
      Types are in the process of being removed. Instead of using a type, prefer to filter on a field on the document.
      The document types to execute the count against. Defaults to be executed against all types.
    • routing

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

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

      public CountRequest indicesOptions(org.elasticsearch.action.support.IndicesOptions indicesOptions)
      Returns the indices options used to resolve indices. They tell for instance whether a single index is accepted, whether an empty array will be converted to _all, and how wildcards will be expanded if needed.
      See Also:
      • IndicesOptions
    • preference

      public CountRequest preference(String preference)
      Sets the preference to execute the count. Defaults to randomize across shards. Can be set to _local to prefer local shards or a custom value, which guarantees that the same order will be used across different requests.
    • indicesOptions

      public org.elasticsearch.action.support.IndicesOptions indicesOptions()
      Specified by:
      indicesOptions in interface org.elasticsearch.action.IndicesRequest
    • routing

      public String routing()
    • preference

      public String preference()
    • indices

      public String[] indices()
      Specified by:
      indices in interface org.elasticsearch.action.IndicesRequest
    • minScore

      public Float minScore()
    • minScore

      public CountRequest minScore(Float minScore)
    • terminateAfter

      public int terminateAfter()
    • terminateAfter

      public CountRequest terminateAfter(int terminateAfter)
    • types

      @Deprecated public String[] types()
      Deprecated.
      Types are in the process of being removed. Instead of using a type, prefer to filter on a field on the document.
    • source

      @Deprecated public org.elasticsearch.search.builder.SearchSourceBuilder source()
      Deprecated.
      The count api only supports a query. Use query() instead.
      Returns:
      the source builder
    • query

      public org.elasticsearch.index.query.QueryBuilder query()
      Returns:
      The provided query to execute with the count request or null if no query was provided.
    • toXContent

      public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.xcontent.ToXContent
      Throws:
      IOException
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object