Skip to content

Commit 64d7de0

Browse files
committed
Add reindex examples
1 parent f0a380b commit 64d7de0

36 files changed

+778
-153
lines changed

output/openapi/elasticsearch-openapi.json

Lines changed: 40 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/openapi/elasticsearch-serverless-openapi.json

Lines changed: 37 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema.json

Lines changed: 98 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/_doc_ids/table.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ docs-multi-termvectors,https://www.elastic.co/guide/en/elasticsearch/reference/{
148148
docs-reindex,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-reindex.html
149149
docs-termvectors,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-termvectors.html
150150
docs-update-by-query,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-update-by-query.html
151-
docs-update-by-query,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-update-by-query.html
152151
docs-update,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/docs-update.html
153152
document-input-parameters,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/query-dsl-mlt-query.html#_document_input_parameters
154153
dot-expand-processor,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/dot-expand-processor.html
@@ -680,6 +679,7 @@ set-processor,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/s
680679
shape,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/shape.html
681680
simulate-ingest-api,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/simulate-ingest-api.html
682681
simulate-pipeline-api,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/simulate-pipeline-api.html
682+
slice-scroll,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/paginate-search-results.html#slice-scroll
683683
slm-api-delete-policy,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/slm-api-delete-policy.html
684684
slm-api-execute-lifecycle,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/slm-api-execute-lifecycle.html
685685
slm-api-execute-retention,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/slm-api-execute-retention.html

specification/_global/reindex/ReindexRequest.ts

Lines changed: 206 additions & 7 deletions
Large diffs are not rendered by default.

specification/_global/reindex/ReindexResponse.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,68 @@ import { DurationValue, EpochTime, UnitMillis } from '@_types/Time'
2525

2626
export class Response {
2727
body: {
28+
/**
29+
* The number of scroll responses that were pulled back by the reindex.
30+
*/
2831
batches?: long
32+
/**
33+
* The number of documents that were successfully created.
34+
*/
2935
created?: long
36+
/**
37+
* The number of documents that were successfully deleted.
38+
*/
3039
deleted?: long
40+
/**
41+
* If there were any unrecoverable errors during the process, it is an array of those failures.
42+
* If this array is not empty, the request ended because of those failures.
43+
* 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.
44+
* You can use the `conflicts` option to prevent the reindex from ending on version conflicts.
45+
*/
3146
failures?: BulkIndexByScrollFailure[]
47+
/**
48+
* The number of documents that were ignored because the script used for the reindex returned a `noop` value for `ctx.op`.
49+
*/
3250
noops?: long
51+
/**
52+
* The number of retries attempted by reindex.
53+
*/
3354
retries?: Retries
55+
/**
56+
* The number of requests per second effectively run during the reindex.
57+
*/
3458
requests_per_second?: float
3559
slice_id?: integer
3660
task?: TaskId
61+
/**
62+
* The number of milliseconds the request slept to conform to `requests_per_second`.
63+
*/
3764
throttled_millis?: EpochTime<UnitMillis>
65+
/**
66+
* This field should always be equal to zero in a reindex response.
67+
* It has meaning only when using the task API, where it indicates the next time (in milliseconds since epoch) that a throttled request will be run again in order to conform to `requests_per_second`.
68+
*/
3869
throttled_until_millis?: EpochTime<UnitMillis>
70+
/**
71+
* If any of the requests that ran during the reindex timed out, it is `true`.
72+
*/
3973
timed_out?: boolean
74+
/**
75+
* The total milliseconds the entire operation took.
76+
*/
4077
took?: DurationValue<UnitMillis>
78+
/**
79+
* The number of documents that were successfully processed.
80+
*/
4181
total?: long
82+
/**
83+
* The number of documents that were successfully updated.
84+
* That is to say, a document with the same ID already existed before the reindex updated it.
85+
*/
4286
updated?: long
87+
/**
88+
* The number of version conflicts that occurred.
89+
*/
4390
version_conflicts?: long
4491
}
4592
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
summary: Reindex multiple sources
2+
# method_request: POST _reindex
3+
description: >
4+
Run `POST _reindex` to reindex from multiple sources.
5+
The `index` attribute in source can be a list, which enables you to copy from lots of sources in one request.
6+
This example copies documents from the `my-index-000001` and `my-index-000002` indices.
7+
# type: request
8+
value: |-
9+
{
10+
"source": {
11+
"index": ["my-index-000001", "my-index-000002"]
12+
},
13+
"dest": {
14+
"index": "my-new-index-000002"
15+
}
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
summary: Reindex with Painless
2+
# method_request: POST _reindex
3+
description: >
4+
You can use Painless to reindex daily indices to apply a new template to the existing documents.
5+
The script extracts the date from the index name and creates a new index with `-1` appended.
6+
For example, all data from `metricbeat-2016.05.31` will be reindexed into `metricbeat-2016.05.31-1`.
7+
# type: request
8+
value:
9+
"{\n \"source\": {\n \"index\": \"metricbeat-*\"\n },\n \"dest\": {\n\
10+
\ \"index\": \"metricbeat\"\n },\n \"script\": {\n \"lang\": \"painless\"\
11+
,\n \"source\": \"ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(),\
12+
\ ctx._index.length())) + '-1'\"\n }\n}"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
summary: Reindex a random subset
2+
# method_request: POST _reindex
3+
description: >
4+
Run `POST _reindex` to extract a random subset of the source for testing.
5+
You might need to adjust the `min_score` value depending on the relative amount of data extracted from source.
6+
# type: request
7+
value:
8+
"{\n \"max_docs\": 10,\n \"source\": {\n \"index\": \"my-index-000001\"\
9+
,\n \"query\": {\n \"function_score\" : {\n \"random_score\" : {},\n\
10+
\ \"min_score\" : 0.9\n }\n }\n },\n \"dest\": {\n \"index\"\
11+
: \"my-new-index-000001\"\n }\n}"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
summary: Reindex modified documents
2+
# method_request: POST _reindex
3+
description: >
4+
Run `POST _reindex` to modify documents during reindexing.
5+
This example bumps the version of the source document.
6+
# type: request
7+
value:
8+
"{\n \"source\": {\n \"index\": \"my-index-000001\"\n },\n \"dest\":\
9+
\ {\n \"index\": \"my-new-index-000001\",\n \"version_type\": \"external\"\
10+
\n },\n \"script\": {\n \"source\": \"if (ctx._source.foo == 'bar') {ctx._version++;\
11+
\ ctx._source.remove('foo')}\",\n \"lang\": \"painless\"\n }\n}"

0 commit comments

Comments
 (0)