elasticsearch,Lucene,elasticsearch" /> elasticsearch,Lucene,elasticsearch" />

Lucene 为什么';使用ElasticSearch批量API进行路由工作?

Lucene 为什么';使用ElasticSearch批量API进行路由工作?,lucene,elasticsearch,Lucene,elasticsearch,我正在将批量请求设置为ElasticSearch,并指定要路由到的碎片 但当我运行它时,文档会被发送到不同的碎片 这是ElasticSEarch批量中的一个bug吗?当我只为单个文档编制索引时,它就起作用了。它在我搜索时起作用。但当我批量进口时就不行了 复制: curl -XPOST 'http://192.168.1.115:9200/_bulk?routing=a' -d ' { "index" : { "_index" : "articles", "_type" : "article",

我正在将批量请求设置为ElasticSearch,并指定要路由到的碎片

但当我运行它时,文档会被发送到不同的碎片

这是ElasticSEarch批量中的一个bug吗?当我只为单个文档编制索引时,它就起作用了。它在我搜索时起作用。但当我批量进口时就不行了

复制:

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"} }'
因此,将“routing”参数添加到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"} }'

@邱英麟答对了,我补充一点:

  • 在es 6.1之前,批量处理时,可以为每个单独的文档使用
    \u传送
    传送
    字段
  • 在es 6.1(包括)之后,您只能使用
    路由

因此,您最好使用
路由
以提高未来的兼容性。

请注意:您报告的问题很快得到了解决,今天发布的问题包含了解决方案。感谢您的报告,您可能需要更新您的答案。我们也在努力编写文档,正如您所知。感谢javanna。但现在我无法指定t批量导入时每个文档的路由字段???如果内存不够,则url中的字段是默认字段,在未指定每个项目时用作备用字段。您救了我!谢谢!