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, 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 ReindexRequest
addSortField(java.lang.String name, SortOrder order)
Add a sort against the given field name.ReindexRequest
forSlice(TaskId slicingTask, SearchRequest slice, int totalSlices)
Build a new request for a slice of the parent request.IndexRequest
getDestination()
Gets the target for this reindex request in the for of anIndexRequest
RemoteInfo
getRemoteInfo()
Get theRemoteInfo
if it was set for this request.void
readFrom(StreamInput in)
Set this object's fields from a StreamInput.protected ReindexRequest
self()
`this` cast to Self.ReindexRequest
setDestDocType(java.lang.String docType)
Set the document type for the destination indexReindexRequest
setDestIndex(java.lang.String destIndex)
Set the target index for the ReindexRequestReindexRequest
setDestOpType(java.lang.String opType)
Sets the optype on the destination indexvoid
setDestPipeline(java.lang.String pipelineName)
Allows to set the ingest pipeline for the target index.ReindexRequest
setDestRouting(java.lang.String routing)
Set the routing to decide which shard the documents need to be routed toReindexRequest
setDestVersionType(VersionType versionType)
Set the version type for the target index.ReindexRequest
setRemoteInfo(RemoteInfo remoteInfo)
Set theRemoteInfo
if the source indices are in a remote cluster.ReindexRequest
setSourceBatchSize(int size)
Sets the scroll size for setting how many documents are to be processed in one batch during reindexReindexRequest
setSourceDocTypes(java.lang.String... docTypes)
Set the document types which need to be copied from the source indicesReindexRequest
setSourceIndices(java.lang.String... sourceIndices)
Set the indices which will act as the source for the ReindexRequestReindexRequest
setSourceQuery(QueryBuilder queryBuilder)
Set the query for selecting documents from the source indicesjava.lang.String
toString()
XContentBuilder
toXContent(XContentBuilder builder, ToXContent.Params params)
ActionRequestValidationException
validate()
void
writeTo(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, getMaxRetries, getRequestsPerSecond, getRetryBackoffInitialTime, getScrollTime, getSearchRequest, getShouldStoreResult, getSize, getSlices, getTimeout, getWaitForActiveShards, isAbortOnVersionConflict, isRefresh, setAbortOnVersionConflict, setConflicts, 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:
self
in classAbstractBulkByScrollRequest<ReindexRequest>
-
validate
public ActionRequestValidationException validate()
- Overrides:
validate
in 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.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 theRemoteInfo
if 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 theRemoteInfo
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 classAbstractBulkByScrollRequest<ReindexRequest>
-
readFrom
public void readFrom(StreamInput in) throws java.io.IOException
Description copied from interface:Streamable
Set this object's fields from a StreamInput.- Specified by:
readFrom
in interfaceStreamable
- Overrides:
readFrom
in classAbstractBulkIndexByScrollRequest<ReindexRequest>
- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:Streamable
Write this object's fields to a StreamOutput.- Specified by:
writeTo
in interfaceStreamable
- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classAbstractBulkIndexByScrollRequest<ReindexRequest>
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContent
in interfaceToXContent
- Throws:
java.io.IOException
-
-