为什么路由不能与ElasticSearch Bulk API一起使用? [英] Why doesn't routing work with ElasticSearch Bulk API?

查看:63
本文介绍了为什么路由不能与ElasticSearch Bulk API一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个批量请求设置为ElasticSearch并指定要路由到的分片.

I am setting a Bulk request to ElasticSearch and specifying the shard to route to.

但是当我运行它时,文档会发送到不同的分片上.

But when I run it, the documents get sent to different shards.

这是ElasticSEarch批量中的错误吗?当我仅对单个文档建立索引时,它就可以工作.搜索时可以使用.但是当我进行批量导入时不会.

Is this a bug in ElasticSEarch bulk? it works when I just index a single document. It works when I search. But not when I do a bulk import.

要复制:

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的末尾是行不通的.

So adding the "routing" parameter to the end of the URL doesn't work.

我需要在实际文档字段中添加"_routing"字段,以指定它将进入的分片.

I need to add the "_routing" field to the actual document fields to specify which shard it will go to.

非常不直观,我希望ElasticSearch会对此进行记录!有时我希望我只是选择Solr:*(

Very unintuitive, and I wish ElasticSearch would've documented this! Sometimes I wish I just chose Solr :*(

希望这可以帮助其他人将来找到它

Hope this helps anyone else looking for this in the future

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"} }'

这篇关于为什么路由不能与ElasticSearch Bulk API一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆