我正在尝试将使用Item gem的tire模型的映射转换为与elasticsearch-rails gem等价的映射:
tire do
mapping(
_parent: { type: 'player' },
_routing: { required: true, path: :user }
) do
indexes :user, type: "string", index: :not_analyzed
end我在elasticsearch-rails中的映射是:
mapping(_parent: {type: 'player', require: 'true', _routing: {path: 'user', required: 'true'}}) do
indexes :user, type: "string", index: not_analyzed
end在我试着引进一些玩家之前,这似乎还可以:
transform_function = lambda do |item|
{
index: {
_id: item.id,
_parent: item.player_id,
_routing: item.user_id,
data: item.__elasticsearch__.as_indexed_json
}
}
Item.__elasticsearch__.import \
index: 'my_index',
batch_size: 100,
transform: transform_function当我试图导入内容时,我会遇到一个错误:
Elasticsearch::Transport::Transport::Errors::BadRequest: [400]
{
"error" : "MapperParsingException[The provided routing value [1] doesn't match the routing key stored in the document: [null]]",
"status":400
}我不知道这个错误意味着什么,我似乎在网上找不到一个适用的解释。其他经历过这种错误的人似乎在做一些不同的事情.
我认为这只是我如何在elasticsearch-rails中声明映射的一个问题。不幸的是,关于这件事应该看上去没有那么多的文件.有人有主意吗?
发布于 2015-11-05 17:45:38
我不知道谁否决了这个问题,但我认为这是一个非常有用的问题。
原来,当你不需要path的时候。实际上,您可以这样设置路由部分:
_routing: {type: 'user', required: 'true'})我希望这能帮上忙。
对于否决这个问题的人来说:也许与其无缘无故地让这个社区不受欢迎,不如添加一个评论来解释为什么这个问题是坏的。
https://stackoverflow.com/questions/33529253
复制相似问题