2015-10-29 18 views
0

使用文档中建议的fake index per user。 ES版本1.6.0有时无法按预期运行。elasticsearch伪造每个用户的索引 - 更新时如何推断路由值?

检查别名:

curl localhost:9200/testbig/_alias/<userId> 
{"<indexname>":{"aliases":{"<userId>":{"filter":{"term": 
{"userId":"<userId>"}},"index_routing":"<userId>","search_routing":"<userId>"}} 
}} 

但试图更新文档:

curl -XPOST localhost:9200/<userId>/<type>/<id>/_update -d 
'{"doc":{"userId":"<userId>","field1":"val1"}}' 

我得到

{ "error": "ElasticsearchIllegalArgumentException[Alias [<userId>] has 
index routing associated with it [<userId>], and was provided with 
routing value [<DIFFERENTuserId>], rejecting operation]", 
"status": 400 } 
+0

您是否已在映射中启用路由并将其指向特定字段? –

回答

0

万一别人遭受类似的问题,是什么原因造成的这个:

如果使用实际的单独的索引为每个用户启动,这是确定以具有相同ID的记录,即路径一样

localhost:9200/userid1/type/id1 
localhost:9200/userid2/type/id1 

但是当userids只是别名,它们分别对应的,当然,在同一文件。因此,路由在后续更新中发生冲突。

相关问题