Document _reindex with random_score

You can use `_reindex` and `random_score` to extract a random
subset of an index but you have to be careful to sort by `_score`
or it won't work.

Closes #21432
This commit is contained in:
Nik Everett 2016-11-10 16:13:05 -05:00
parent 179dd885e2
commit eeb6602c98
1 changed files with 31 additions and 0 deletions

View File

@ -935,3 +935,34 @@ GET metricbeat-2016.05.31-1/beat/1
The previous method can also be used in combination with <<docs-reindex-change-name, change the name of a field>> The previous method can also be used in combination with <<docs-reindex-change-name, change the name of a field>>
to only load the existing data into the new index, but also rename fields if needed. to only load the existing data into the new index, but also rename fields if needed.
[float]
=== Extracting a random subset of an index
Reindex can be used to extract a random subset of an index for testing:
[source,js]
----------------------------------------------------------------
POST _reindex
{
"size": 10,
"source": {
"index": "twitter",
"query": {
"function_score" : {
"query" : { "match_all": {} },
"random_score" : {}
}
},
"sort": "_score" <1>
},
"dest": {
"index": "random_twitter"
}
}
----------------------------------------------------------------
// CONSOLE
// TEST[setup:big_twitter]
<1> Reindex defaults to sorting by `_doc` so `random_score` won't have any
effect unless you override the sort to `_score`.