Class UpdateByQueryRequest

All Implemented Interfaces:
IndicesRequest, IndicesRequest.Replaceable, Writeable, org.elasticsearch.common.util.concurrent.RefCounted, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject, TaskAwareRequest

public class UpdateByQueryRequest
extends AbstractBulkIndexByScrollRequest<UpdateByQueryRequest>
implements IndicesRequest.Replaceable, org.elasticsearch.common.xcontent.ToXContentObject
Request to update some documents. That means you can't change their type, id, index, or anything like that. This implements CompositeIndicesRequest but in a misleading way. Rather than returning all the subrequests that it will make it tries to return a representative set of subrequests. This is best-effort but better than ReindexRequest because scripts can't change the destination index and things.
  • Constructor Details

    • UpdateByQueryRequest

      public UpdateByQueryRequest()
    • UpdateByQueryRequest

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

      public UpdateByQueryRequest​(StreamInput in) throws java.io.IOException
      Throws:
      java.io.IOException
  • Method Details

    • setPipeline

      public UpdateByQueryRequest setPipeline​(java.lang.String pipeline)
      Set the ingest pipeline to set on index requests made by this action.
    • setQuery

      public UpdateByQueryRequest setQuery​(QueryBuilder query)
      Set the query for selective update
    • setDocTypes

      @Deprecated public UpdateByQueryRequest 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 update
    • setRouting

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

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

      public UpdateByQueryRequest setIndicesOptions​(IndicesOptions indicesOptions)
      Set the IndicesOptions for controlling unavailable indices
    • 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.
    • getPipeline

      public java.lang.String getPipeline()
      Ingest pipeline to set on index requests made by this action.
    • self

      protected UpdateByQueryRequest self()
      Description copied from class: AbstractBulkByScrollRequest
      `this` cast to Self. Used for building fluent methods without cast warnings.
      Specified by:
      self in class AbstractBulkByScrollRequest<UpdateByQueryRequest>
    • forSlice

      public UpdateByQueryRequest forSlice​(TaskId slicingTask, SearchRequest slice, int totalSlices)
      Description copied from class: AbstractBulkByScrollRequest
      Build a new request for a slice of the parent request.
      Specified by:
      forSlice in class AbstractBulkByScrollRequest<UpdateByQueryRequest>
    • toString

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

      public IndicesRequest indices​(java.lang.String... indices)
      Description copied from interface: IndicesRequest.Replaceable
      Sets the indices that the action relates to.
      Specified by:
      indices in interface IndicesRequest.Replaceable
    • 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
    • writeTo

      public void writeTo​(StreamOutput out) throws java.io.IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Overrides:
      writeTo in class AbstractBulkIndexByScrollRequest<UpdateByQueryRequest>
      Throws:
      java.io.IOException
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      java.io.IOException