Package org.elasticsearch.index.reindex
Class ReindexRequest
- java.lang.Object
-
- org.elasticsearch.transport.TransportMessage
-
- org.elasticsearch.transport.TransportRequest
-
- org.elasticsearch.action.ActionRequest
-
- org.elasticsearch.index.reindex.AbstractBulkByScrollRequest<Self>
-
- org.elasticsearch.index.reindex.AbstractBulkIndexByScrollRequest<ReindexRequest>
-
- org.elasticsearch.index.reindex.ReindexRequest
-
- All Implemented Interfaces:
CompositeIndicesRequest,Streamable,Writeable,ToXContent,ToXContentObject,TaskAwareRequest
public class ReindexRequest extends AbstractBulkIndexByScrollRequest<ReindexRequest> implements CompositeIndicesRequest, 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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.elasticsearch.transport.TransportRequest
TransportRequest.Empty
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested 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_MATCHES, SIZE_ALL_MATCHES
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description ReindexRequest()ReindexRequest(StreamInput in)
-
Method Summary
Modifier and Type Method Description ReindexRequestaddSortField(java.lang.String name, SortOrder order)Add a sort against the given field name.ReindexRequestforSlice(TaskId slicingTask, SearchRequest slice, int totalSlices)Build a new request for a slice of the parent request.static ReindexRequestfromXContent(XContentParser parser)IndexRequestgetDestination()Gets the target for this reindex request in the for of anIndexRequestRemoteInfogetRemoteInfo()Get theRemoteInfoif it was set for this request.voidreadFrom(StreamInput in)Set this object's fields from a StreamInput.protected ReindexRequestself()`this` cast to Self.ReindexRequestsetDestDocType(java.lang.String docType)Set the document type for the destination indexReindexRequestsetDestIndex(java.lang.String destIndex)Set the target index for the ReindexRequestReindexRequestsetDestOpType(java.lang.String opType)Sets the optype on the destination indexvoidsetDestPipeline(java.lang.String pipelineName)Allows to set the ingest pipeline for the target index.ReindexRequestsetDestRouting(java.lang.String routing)Set the routing to decide which shard the documents need to be routed toReindexRequestsetDestVersionType(VersionType versionType)Set the version type for the target index.ReindexRequestsetRemoteInfo(RemoteInfo remoteInfo)Set theRemoteInfoif the source indices are in a remote cluster.ReindexRequestsetSourceBatchSize(int size)Sets the scroll size for setting how many documents are to be processed in one batch during reindexReindexRequestsetSourceDocTypes(java.lang.String... docTypes)Set the document types which need to be copied from the source indicesReindexRequestsetSourceIndices(java.lang.String... sourceIndices)Set the indices which will act as the source for the ReindexRequestReindexRequestsetSourceQuery(QueryBuilder queryBuilder)Set the query for selecting documents from the source indicesjava.lang.StringtoString()XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)ActionRequestValidationExceptionvalidate()voidwriteTo(StreamOutput out)Write this object's fields to a StreamOutput.-
Methods inherited from class org.elasticsearch.index.reindex.AbstractBulkIndexByScrollRequest
doForSlice, getScript, searchToString, setScript
-
Methods inherited from class org.elasticsearch.index.reindex.AbstractBulkByScrollRequest
createTask, getDescription, getMaxDocs, getMaxRetries, getRequestsPerSecond, getRetryBackoffInitialTime, getScrollTime, getSearchRequest, getShouldStoreResult, getSize, getSlices, getTimeout, getWaitForActiveShards, isAbortOnVersionConflict, isRefresh, setAbortOnVersionConflict, setConflicts, setMaxDocs, setMaxRetries, setRefresh, setRequestsPerSecond, setRetryBackoffInitialTime, setScroll, setShouldStoreResult, setSize, setSlices, setTimeout, setTimeout, setWaitForActiveShards, setWaitForActiveShards
-
Methods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, setParentTask
-
Methods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddress
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.tasks.TaskAwareRequest
setParentTask
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Constructor Detail
-
ReindexRequest
public ReindexRequest()
-
ReindexRequest
public ReindexRequest(StreamInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
self
protected ReindexRequest self()
Description copied from class:AbstractBulkByScrollRequest`this` cast to Self. Used for building fluent methods without cast warnings.- Specified by:
selfin classAbstractBulkByScrollRequest<ReindexRequest>
-
validate
public ActionRequestValidationException validate()
- Overrides:
validatein classAbstractBulkByScrollRequest<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
public ReindexRequest addSortField(java.lang.String name, SortOrder order)
Add a sort against the given field name.- Parameters:
name- The name of the field to sort byorder- 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. AVersionType.EXTERNALhelps 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 theRemoteInfoif the source indices are in a remote cluster.
-
getDestination
public IndexRequest getDestination()
Gets the target for this reindex request in the for of anIndexRequest
-
getRemoteInfo
public RemoteInfo getRemoteInfo()
Get theRemoteInfoif it was set for this request.
-
forSlice
public ReindexRequest forSlice(TaskId slicingTask, SearchRequest slice, int totalSlices)
Description copied from class:AbstractBulkByScrollRequestBuild a new request for a slice of the parent request.- Specified by:
forSlicein classAbstractBulkByScrollRequest<ReindexRequest>
-
readFrom
public void readFrom(StreamInput in) throws java.io.IOException
Description copied from interface:StreamableSet this object's fields from a StreamInput.- Specified by:
readFromin interfaceStreamable- Overrides:
readFromin classAbstractBulkIndexByScrollRequest<ReindexRequest>- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:StreamableWrite this object's fields to a StreamOutput.- Specified by:
writeToin interfaceStreamable- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classAbstractBulkIndexByScrollRequest<ReindexRequest>- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContentin interfaceToXContent- Throws:
java.io.IOException
-
fromXContent
public static ReindexRequest fromXContent(XContentParser parser) throws java.io.IOException
- Throws:
java.io.IOException
-
-