我正在尝试将来自远程Elasticsearch 2.4集群的随机文档样本重新索引到新的Elasticsearch 6.5集群中。我正在尝试使此示例(https://www.elastic.co/guide/en/elasticsearch/reference/6.5/docs-reindex.html#_extracting_a_random_subset_of_an_index)适用于远程重新索引编制:
示例:
POST _reindex
{
"size": 10,
"source": {
"index": "twitter",
"query": {
"function_score" : {
"query" : { "match_all": {} },
"random_score" : {}
}
},
"sort": "_score"
},
"dest": {
"index": "random_twitter"
}
}
适用于远程重新索引:
curl -H "Content-Type: application/json" -X POST localhost:9200/_reindex -d '
{
"size": 100,
"source": {
"remote": {
"host": "http://REMOTE_HOST:9200"
},
"index": "myindex",
"query": {
"function_score" : {
"query" : { "match_all": {} },
"random_score" : {}
}
},
"sort": "_score"
},
"dest": {
"index": "myindex"
}
}'
这将返回状态代码400和以下消息:
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Unsupported sort [{\n \"_score\" : {\n \"order\" : \"desc\"\n }\n}]"}],"type":"illegal_argument_exception","reason":"Unsupported sort [{\n \"_score\" : {\n \"order\" : \"desc\"\n }\n}]"},"status":400}
因此,按_score排序似乎无效。当我删除_score排序时,它可以正常工作-但是,如文档中所述,样本并不是真正随机的。
从远程重新编制索引时这是不可能的,还是我做错了什么? ;)
答案 0 :(得分:0)
我会尝试指定这样的排序方式:
"sort": {"_score": "desc" }