java.lang.Object
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.TransportRequest
org.elasticsearch.action.ActionRequest
org.elasticsearch.action.LegacyActionRequest
org.elasticsearch.index.reindex.AbstractBulkByScrollRequest<DeleteByQueryRequest>
org.elasticsearch.index.reindex.DeleteByQueryRequest
- All Implemented Interfaces:
IndicesRequest,IndicesRequest.Replaceable,Writeable,RefCounted,TaskAwareRequest,ToXContent,ToXContentObject
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-timesnapshot, 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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.action.IndicesRequest
IndicesRequest.RemoteClusterShardRequest, IndicesRequest.Replaceable, IndicesRequest.SingleIndexNoWildcardsNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields inherited from class org.elasticsearch.index.reindex.AbstractBulkByScrollRequest
AUTO_SLICES, AUTO_SLICES_VALUE, DEFAULT_SCROLL_SIZE, DEFAULT_SCROLL_TIMEOUT, MAX_DOCS_ALL_MATCHESFields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCEDFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionforSlice(TaskId slicingTask, SearchRequest slice, int totalSlices) Build a new request for a slice of the parent request.intGets the batch size for this requestGets the routing value used for this requestbooleanDetermines whether the request should be applied to data streams.String[]indices()Returns the array of indices that the action relates toSets the indices that the action relates to.Returns the indices options used to resolve indices.protected DeleteByQueryRequestself()`this` cast to Self.setBatchSize(int size) The scroll size to control number of documents processed per batchsetIndicesOptions(IndicesOptions indicesOptions) Set the IndicesOptions for controlling unavailable indicessetQuery(QueryBuilder query) Set the query for selective deletesetRouting(String routing) Set routing limiting the process to the shards that match that routing valuetoString()toXContent(XContentBuilder builder, ToXContent.Params params) validate()Methods inherited from class org.elasticsearch.index.reindex.AbstractBulkByScrollRequest
createTask, doForSlice, getDescription, getMaxDocs, getMaxRetries, getRequestsPerSecond, getRetryBackoffInitialTime, getScrollTime, getSearchRequest, getShouldStoreResult, getSlices, getTimeout, getWaitForActiveShards, isAbortOnVersionConflict, isRefresh, searchToString, setAbortOnVersionConflict, setConflicts, setMaxDocs, setMaxRetries, setRefresh, setRequestsPerSecond, setRetryBackoffInitialTime, setScroll, setShouldStoreResult, setSlices, setTimeout, setWaitForActiveShards, setWaitForActiveShards, writeToMethods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, getRequestId, setParentTask, setRequestIdMethods inherited from class org.elasticsearch.transport.TransportMessage
decRef, hasReferences, incRef, remoteAddress, remoteAddress, tryIncRefMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.action.IndicesRequest.Replaceable
allowsRemoteIndicesMethods inherited from interface org.elasticsearch.core.RefCounted
mustIncRefMethods inherited from interface org.elasticsearch.tasks.TaskAwareRequest
setParentTaskMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Constructor Details
-
DeleteByQueryRequest
public DeleteByQueryRequest() -
DeleteByQueryRequest
-
DeleteByQueryRequest
- Throws:
IOException
-
-
Method Details
-
setQuery
Set the query for selective delete -
setRouting
Set routing limiting the process to the shards that match that routing value -
setBatchSize
The scroll size to control number of documents processed per batch -
setIndicesOptions
Set the IndicesOptions for controlling unavailable indices -
getBatchSize
public int getBatchSize()Gets the batch size for this request -
getRouting
Gets the routing value used for this request -
self
Description copied from class:AbstractBulkByScrollRequest`this` cast to Self. Used for building fluent methods without cast warnings.- Specified by:
selfin classAbstractBulkByScrollRequest<DeleteByQueryRequest>
-
includeDataStreams
public boolean includeDataStreams()Description copied from interface:IndicesRequestDetermines whether the request should be applied to data streams. Whenfalse, none of the names or wildcard expressions inIndicesRequest.indices()should be applied to or expanded to any data streams. All layers involved in the request's fulfillment including security, name resolution, etc., should respect this flag.- Specified by:
includeDataStreamsin interfaceIndicesRequest
-
validate
- Overrides:
validatein classAbstractBulkByScrollRequest<DeleteByQueryRequest>
-
forSlice
Description copied from class:AbstractBulkByScrollRequestBuild a new request for a slice of the parent request.- Specified by:
forSlicein classAbstractBulkByScrollRequest<DeleteByQueryRequest>
-
toString
- Overrides:
toStringin classTransportRequest
-
indices
Description copied from interface:IndicesRequest.ReplaceableSets the indices that the action relates to.- Specified by:
indicesin interfaceIndicesRequest.Replaceable
-
indices
Description copied from interface:IndicesRequestReturns the array of indices that the action relates to- Specified by:
indicesin interfaceIndicesRequest
-
indicesOptions
Description copied from interface:IndicesRequestReturns 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:
indicesOptionsin interfaceIndicesRequest
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-