Class DeleteByQueryRequest

  • All Implemented Interfaces:
    IndicesRequest, IndicesRequest.Replaceable, Writeable, ToXContent, ToXContentObject, TaskAwareRequest

    public class DeleteByQueryRequest
    extends AbstractBulkByScrollRequest<DeleteByQueryRequest>
    implements IndicesRequest.Replaceable, ToXContentObject
    Creates a new DeleteByQueryRequest that uses scrolling and bulk requests to delete all documents matching the query. This can have performance as well as visibility implications. Delete-by-query now has the following semantics:
    • it's non-atomic, a delete-by-query may fail at any time while some documents matching the query have already been deleted
    • it's syntactic sugar, a delete-by-query is equivalent to a scroll search and corresponding bulk-deletes by ID
    • it's executed on a point-in-time snapshot, a delete-by-query will only delete the documents that are visible at the point in time the delete-by-query was started, equivalent to the scroll API
    • it's consistent, a delete-by-query will yield consistent results across all replicas of a shard
    • it's forward-compatible, a delete-by-query will only send IDs to the shards as deletes such that no queries are stored in the transaction logs that might not be supported in the future.
    • it's results won't be visible until the index is refreshed.
    • Constructor Detail

      • DeleteByQueryRequest

        public DeleteByQueryRequest()
      • DeleteByQueryRequest

        public DeleteByQueryRequest​(java.lang.String... indices)
      • DeleteByQueryRequest

        public DeleteByQueryRequest​(StreamInput in)
                             throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • setDocTypes

        @Deprecated
        public DeleteByQueryRequest setDocTypes​(java.lang.String... types)
        Deprecated.
        Types are in the process of being removed. Instead of using a type, prefer to filter on a field of the document.
        Set the document types for the delete
      • setRouting

        public DeleteByQueryRequest setRouting​(java.lang.String routing)
        Set routing limiting the process to the shards that match that routing value
      • setBatchSize

        public DeleteByQueryRequest setBatchSize​(int size)
        The scroll size to control number of documents processed per batch
      • getBatchSize

        public int getBatchSize()
        Gets the batch size for this request
      • getRouting

        public java.lang.String getRouting()
        Gets the routing value used for this request
      • getDocTypes

        @Deprecated
        public java.lang.String[] getDocTypes()
        Deprecated.
        Types are in the process of being removed. Instead of using a type, prefer to filter on a field of the document.
        Gets the document types on which this request would be executed. Returns an empty array if all types are to be processed.
      • toString

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

        public java.lang.String[] indices()
        Description copied from interface: IndicesRequest
        Returns the array of indices that the action relates to
        Specified by:
        indices in interface IndicesRequest
      • indicesOptions

        public IndicesOptions indicesOptions()
        Description copied from interface: IndicesRequest
        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.
        Specified by:
        indicesOptions in interface IndicesRequest
      • types

        @Deprecated
        public java.lang.String[] types()
        Deprecated.
        Types are in the process of being removed. Instead of using a type, prefer to filter on a field of the document.
        Gets the document types on which this request would be executed.
      • types

        @Deprecated
        public DeleteByQueryRequest types​(java.lang.String... types)
        Deprecated.
        Types are in the process of being removed. Instead of using a type, prefer to filter on a field of the document.
        Set the document types for the delete