Reindex documents | Elasticsearch API documentation (original) (raw)
Dismiss highlight Show more
Query parameters
- If
true, the request refreshes affected shards to make this operation visible to search. - requests_per_second
number
The throttle for this request in sub-requests per second. By default, there is no throttle. - The period of time that a consistent view of the index should be maintained for scrolled search.
External documentation - The number of slices this task should be divided into. It defaults to one slice, which means the task isn't sliced into subtasks.
Reindex supports sliced scroll to parallelize the reindexing process. This parallelization can improve efficiency and provide a convenient way to break the request down into smaller parts.
NOTE: Reindexing from remote clusters does not support manual or automatic slicing.
If set toauto, Elasticsearch chooses the number of slices to use. This setting will use one slice per shard, up to a certain limit. If there are multiple sources, it will choose the number of slices based on the index or backing index with the smallest number of shards. - The maximum number of documents to reindex. By default, all documents are reindexed. If it is a value less then or equal to
scroll_size, a scroll will not be used to retrieve the results for the operation.
Ifconflictsis set toproceed, the reindex operation could attempt to reindex more documents from the source thanmax_docsuntil it has successfully indexedmax_docsdocuments into the target or it has gone through every document in the source query. - The period each indexing waits for automatic index creation, dynamic mapping updates, and waiting for active shards. By default, Elasticsearch waits for at least one minute before failing. The actual wait time could be longer, particularly when multiple waits occur.
External documentation - wait_for_active_shards
number | string
The number of shard copies that must be active before proceeding with the operation. Set it toallor any positive integer up to the total number of shards in the index (number_of_replicas+1). The default value is one, which means it waits for each primary shard to be active.
Values areallorindex-setting. - wait_for_completion
boolean
Iftrue, the request blocks until the operation is complete. - If
true, the destination must be an index alias.
application/json
Body Required
- Indicates whether to continue reindexing even when there are conflicts.
Supported values include:abort: Stop reindexing if there are conflicts.proceed: Continue reindexing even if there are conflicts.
Values areabortorproceed.
- The destination you are copying to.
Hide dest attributes Show dest attributes object- The name of the data stream, index, or index alias you are copying to.
- If it is
create, the operation will only index documents that do not already exist (also known as "put if absent").
IMPORTANT: To reindex to a data stream destination, this argument must becreate.
Supported values include:
*index: Overwrite any documents that already exist.
*create: Only index documents that do not already exist.
Values are
indexorcreate.By default, a document's routing is preserved unless it's changed by the script. If it is
keep, the routing on the bulk request sent for each match is set to the routing on the match. If it isdiscard, the routing on the bulk request sent for each match is set tonull. If it is=value, the routing on the bulk request sent for each match is set to all value specified after the equals sign (=).
By default, a document's routing is preserved unless it's changed by the script. If it iskeep, the routing on the bulk request sent for each match is set to the routing on the match. If it isdiscard, the routing on the bulk request sent for each match is set tonull. If it is=value, the routing on the bulk request sent for each match is set to all value specified after the equals sign (=).
By default, a document's routing is preserved unless it's changed by the script. If it iskeep, the routing on the bulk request sent for each match is set to the routing on the match. If it isdiscard, the routing on the bulk request sent for each match is set tonull. If it is=value, the routing on the bulk request sent for each match is set to all value specified after the equals sign (=).- The versioning to use for the indexing operation.
Supported values include:
*internal: Use internal versioning that starts at 1 and increments with each update or delete.
*external: Only index the document if the specified version is strictly higher than the version of the stored document or if there is no existing document.
*external_gte: Only index the document if the specified version is equal or higher than the version of the stored document or if there is no existing document. NOTE: Theexternal_gteversion type is meant for special use cases and should be used with care. If used incorrectly, it can result in loss of data.
Values are
internal,external, orexternal_gte. - The maximum number of documents to reindex. By default, all documents are reindexed. If it is a value less then or equal to
scroll_size, a scroll will not be used to retrieve the results for the operation.
Ifconflictsis set toproceed, the reindex operation could attempt to reindex more documents from the source thanmax_docsuntil it has successfully indexedmax_docsdocuments into the target or it has gone through every document in the source query. - The script to run to update the document source or metadata when reindexing.
Hide script attributes Show script attributes objectThe script source.
- The
idfor a stored script. - Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.
Hide params attribute Show params attribute object
* *
object Additional properties lang string
Specifies the language the script is written in.
Supported values include:
*painless: Painless scripting language, purpose-built for Elasticsearch.
*expression: Lucene’s expressions language, compiles a JavaScript expression to bytecode.
*mustache: Mustache templated, used for templates.
*java: Expert Java API
Specifies the language the script is written in.
Supported values include:
*painless: Painless scripting language, purpose-built for Elasticsearch.
*expression: Lucene’s expressions language, compiles a JavaScript expression to bytecode.
*mustache: Mustache templated, used for templates.
*java: Expert Java API
Values arepainless,expression,mustache, orjava.
Specifies the language the script is written in.
Supported values include:
*painless: Painless scripting language, purpose-built for Elasticsearch.
*expression: Lucene’s expressions language, compiles a JavaScript expression to bytecode.
*mustache: Mustache templated, used for templates.
*java: Expert Java API - The
- The source you are copying from.
Hide source attributes Show source attributes object- index
string | array[string] Required
The name of the data stream, index, or alias you are copying from. It accepts a comma-separated list to reindex from multiple sources. - The documents to reindex, which is defined with Query DSL.
External documentation - A remote instance of Elasticsearch that you want to index from.
Hide remote attributes Show remote attributes object
* The remote connection timeout.
External documentation
* An object containing the headers of the request.
Hide headers attribute Show headers attribute object
* *
string Additional properties
* The URL for the remote instance of Elasticsearch that you want to index from. This information is required when you're indexing from remote.
* The username to use for authentication with the remote host (required when using basic auth).
* The password to use for authentication with the remote host (required when using basic auth).
* api_key
string Generally available; Added in 9.3.0
The API key to use for authentication with the remote host (as an alternative to basic auth when the remote cluster is in Elastic Cloud). (It is not permitted to set this and also to set anAuthorizationheader viaheaders.)
* The remote socket read timeout.
External documentation - The number of documents to index per batch. Use it when you are indexing from remote to ensure that the batches fit within the on-heap buffer, which defaults to a maximum size of 100 MB.
- Slice the reindex request manually using the provided slice ID and total number of slices.
Hide slice attributes Show slice attributes object
* Path to field or array of paths. Some API's support wildcards in the path to select multiple fields. sort string | object | array[string | object]
A comma-separated list of
<field>:<direction>pairs to sort by before indexing. Use it in conjunction withmax_docsto control what documents are reindexed.
WARNING: Sort in reindex is deprecated. Sorting in reindex was never guaranteed to index documents in order and prevents further development of reindex such as resilience and performance improvements. If used in combination withmax_docs, consider using a query filter instead.
A comma-separated list of<field>:<direction>pairs to sort by before indexing. Use it in conjunction withmax_docsto control what documents are reindexed.
WARNING: Sort in reindex is deprecated. Sorting in reindex was never guaranteed to index documents in order and prevents further development of reindex such as resilience and performance improvements. If used in combination withmax_docs, consider using a query filter instead.
A comma-separated list of<field>:<direction>pairs to sort by before indexing. Use it in conjunction withmax_docsto control what documents are reindexed.
WARNING: Sort in reindex is deprecated. Sorting in reindex was never guaranteed to index documents in order and prevents further development of reindex such as resilience and performance improvements. If used in combination withmax_docs, consider using a query filter instead.
A comma-separated list of<field>:<direction>pairs to sort by before indexing. Use it in conjunction withmax_docsto control what documents are reindexed.
WARNING: Sort in reindex is deprecated. Sorting in reindex was never guaranteed to index documents in order and prevents further development of reindex such as resilience and performance improvements. If used in combination withmax_docs, consider using a query filter instead.If
true, reindex all source fields. Set it to a list to reindex select fields.
Iftrue, reindex all source fields. Set it to a list to reindex select fields.- Hide runtime_mappings attribute Show runtime_mappings attribute object
* *
object Additional properties
Hide * attributes Show * attributes object
* For typecomposite
Hide fields attribute Show fields attribute object
* *
object Additional properties
* fetch_fields
array[object]
For typelookup
* A custom format fordatetype runtime fields.
* For typelookup
* For typelookup
* For typelookup
* Painless script executed at query time.
* Field type, which can be:boolean,composite,date,double,geo_point,ip,keyword,long, orlookup.
Values areboolean,composite,date,double,geo_point,geo_shape,ip,keyword,long, orlookup.
- index
Responses
- 200 application/json
Hide response attributes Show response attributes object- The number of scroll responses that were pulled back by the reindex.
- The number of documents that were successfully created.
- The number of documents that were successfully deleted.
- If there were any unrecoverable errors during the process, it is an array of those failures. If this array is not empty, the request ended because of those failures. Reindex is implemented using batches and any failure causes the entire process to end but all failures in the current batch are collected into the array. You can use the
conflictsoption to prevent the reindex from ending on version conflicts.
Hide failures attributes Show failures attributes object
* Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.
Hide cause attributes Show cause attributes object
* The type of error
* #### reason string | null
A human-readable explanation of the error, in English.
* The server stack trace. Present only if theerror_trace=trueparameter was sent with the request.
* Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.
* Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.
Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.
* Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.
Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type. - The number of documents that were ignored because the script used for the reindex returned a
noopvalue forctx.op. - The number of retries attempted by reindex.
Hide retries attributes Show retries attributes object
* The number of bulk actions retried.
* The number of search actions retried. - requests_per_second
number
The number of requests per second effectively run during the reindex. - Time unit for milliseconds
- throttled_until_millis
number
Time unit for milliseconds - If any of the requests that ran during the reindex timed out, it is
true. - Time unit for milliseconds
- The number of documents that were successfully processed.
- The number of documents that were successfully updated. That is to say, a document with the same ID already existed before the reindex updated it.
- The number of version conflicts that occurred.