Class ReindexRequest

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

public class ReindexRequest
extends AbstractBulkIndexByScrollRequest<ReindexRequest>
implements CompositeIndicesRequest, org.elasticsearch.common.xcontent.ToXContentObject
Request to reindex some documents from one index to another. 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 for a bunch of reasons, not least of which that scripts are allowed to change the destination request in drastic ways, including changing the index to which documents are written.
  • Constructor Details

    • ReindexRequest

      public ReindexRequest()
    • ReindexRequest

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

    • self

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

      Overrides:
      validate in class AbstractBulkByScrollRequest<ReindexRequest>
    • setSourceIndices

      public ReindexRequest setSourceIndices​(java.lang.String... sourceIndices)
      Set the indices which will act as the source for the ReindexRequest
    • setSourceDocTypes

      public ReindexRequest setSourceDocTypes​(java.lang.String... docTypes)
      Set the document types which need to be copied from the source indices
    • setSourceBatchSize

      public ReindexRequest setSourceBatchSize​(int size)
      Sets the scroll size for setting how many documents are to be processed in one batch during reindex
    • setSourceQuery

      public ReindexRequest setSourceQuery​(QueryBuilder queryBuilder)
      Set the query for selecting documents from the source indices
    • addSortField

      @Deprecated public ReindexRequest addSortField​(java.lang.String name, SortOrder order)
      Deprecated.
      Specifying a sort field for reindex is deprecated. If using this in combination with maxDocs, consider using a query filter instead.
      Add a sort against the given field name.
      Parameters:
      name - The name of the field to sort by
      order - The order in which to sort
    • setDestIndex

      public ReindexRequest setDestIndex​(java.lang.String destIndex)
      Set the target index for the ReindexRequest
    • setDestDocType

      public ReindexRequest setDestDocType​(java.lang.String docType)
      Set the document type for the destination index
    • setDestRouting

      public ReindexRequest setDestRouting​(java.lang.String routing)
      Set the routing to decide which shard the documents need to be routed to
    • setDestVersionType

      public ReindexRequest setDestVersionType​(VersionType versionType)
      Set the version type for the target index. A VersionType.EXTERNAL helps preserve the version if the document already existed in the target index.
    • setDestPipeline

      public void setDestPipeline​(java.lang.String pipelineName)
      Allows to set the ingest pipeline for the target index.
    • setDestOpType

      public ReindexRequest setDestOpType​(java.lang.String opType)
      Sets the optype on the destination index
      Parameters:
      opType - must be one of {create, index}
    • setRemoteInfo

      public ReindexRequest setRemoteInfo​(RemoteInfo remoteInfo)
      Set the RemoteInfo if the source indices are in a remote cluster.
    • setRequireAlias

      public ReindexRequest setRequireAlias​(boolean requireAlias)
      Sets the require_alias request flag on the destination index
    • getDestination

      public IndexRequest getDestination()
      Gets the target for this reindex request in the for of an IndexRequest
    • getRemoteInfo

      public RemoteInfo getRemoteInfo()
      Get the RemoteInfo if it was set for this request.
    • forSlice

      public ReindexRequest 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<ReindexRequest>
    • 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<ReindexRequest>
      Throws:
      java.io.IOException
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • 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
    • fromXContent

      public static ReindexRequest fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException
      Throws:
      java.io.IOException