Skip to content

Commit aa13165

Browse files
committed
Docs: Advice for reindexing many indices (#31279)
Folks tend to want to be able to make a single `_reindex` call to migrate many indices. You *can* do that and we even have an example of how to do that in the docs but it isn't always a good idea. This change adds some advice to the docs: generally you want to make one reindex call per index. Closes #22920
1 parent a4c9ebc commit aa13165

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

docs/reference/docs/reindex.asciidoc

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,11 +1025,38 @@ number of slices.
10251025
Whether query or indexing performance dominates the runtime depends on the
10261026
documents being reindexed and cluster resources.
10271027

1028+
[float]
1029+
=== Reindexing many indices
1030+
If you have many indices to reindex it is generally better to reindex them
1031+
one at a time rather than using a glob pattern to pick up many indices. That
1032+
way you can resume the process if there are any errors by removing the
1033+
partially completed index and starting over at that index. It also makes
1034+
parallelizing the process fairly simple: split the list of indices to reindex
1035+
and run each list in parallel.
1036+
1037+
One off bash scripts seem to work nicely for this:
1038+
1039+
[source,bash]
1040+
----------------------------------------------------------------
1041+
for index in i1 i2 i3 i4 i5; do
1042+
curl -HContent-Type:application/json -XPOST localhost:9200/_reindex?pretty -d'{
1043+
"source": {
1044+
"index": "'$index'"
1045+
},
1046+
"dest": {
1047+
"index": "'$index'-reindexed"
1048+
}
1049+
}'
1050+
done
1051+
----------------------------------------------------------------
1052+
// NOTCONSOLE
1053+
10281054
[float]
10291055
=== Reindex daily indices
10301056

1031-
You can use `_reindex` in combination with <<modules-scripting-painless, Painless>>
1032-
to reindex daily indices to apply a new template to the existing documents.
1057+
Notwithstanding the above advice, you can use `_reindex` in combination with
1058+
<<modules-scripting-painless, Painless>> to reindex daily indices to apply
1059+
a new template to the existing documents.
10331060

10341061
Assuming you have indices consisting of documents as follows:
10351062

0 commit comments

Comments
 (0)