Hen*_*hiu 3 lucene elasticsearch
我正在向ElasticSearch设置批量请求并指定要路由到的分片.
但是当我运行它时,文档会被发送到不同的分片.
这是ElasticSEarch批量中的错误吗?它只在索引单个文档时有效.它在我搜索时有效.但是当我进行批量导入时.
重现:
curl -XPOST 'http://192.168.1.115:9200/_bulk?routing=a' -d '
{ "index" : { "_index" : "articles", "_type" : "article", "_id" : "1" } }
{ "title" : "value1" }
{ "delete" : { "_index" : "articles", "_type" : "article", "_id" : "2" } }
{ "create" : { "_index" : "articles", "_type" : "article", "_id" : "3" } }
{ "title" : "value3" }
{ "update" : {"_id" : "1", "_type" : "article", "_index" : "index1"} }
{ "doc" : {"field2" : "value2"} }'
Run Code Online (Sandbox Code Playgroud)
Hen*_*hiu 10
因此,将"路由"参数添加到URL的末尾不起作用.
我需要将"_routing"字段添加到实际的文档字段中,以指定它将转到哪个分片.
非常不直观,我希望ElasticSearch能够记录下这一点!有时我希望我选择Solr:*(
希望这可以帮助其他人在将来寻找这个
curl -XPOST 'http://192.168.1.115:9200/_bulk?routing=a' -d '
{ "index" : { "_index" : "articles", "_type" : "article", "_id" : "1", "_routing" : "b"} }
{ "title" : "value1" }
{ "delete" : { "_index" : "articles", "_type" : "article", "_id" : "2", "_routing" : "b" } }
{ "create" : { "_index" : "articles", "_type" : "article", "_id" : "3", "_routing" : "b" } }
{ "title" : "value3" }
{ "update" : {"_id" : "1", "_type" : "article", "_index" : "index1", "_routing" : "b"} }
{ "doc" : {"field2" : "value2"} }'
Run Code Online (Sandbox Code Playgroud)
@Henley Chiu 给出了正确答案,我补充一个细节:
_routing或routing字段routing所以,routing为了更好的未来兼容性,你最好使用。