我有2個模型,Player
和Item
。 A player
有許多items
。如何使用Tire指示父/子關係中的對象的父對象
的Item
模型的映射:
tire do
mapping(
_parent: { type: 'player' },
_routing: { required: true, path: :user }
) do
indexes :user, type: "string", index: :not_analyzed
end
(不知道path
的選擇是什麼,但它可能被用來存儲在不同的碎片的項目
什麼我不能?我想知道如何在保存item
時指定player
(父母)。在我找到的所有父母/子女關係示例中,他們只使用CURL:
curl -XPOST localhost:9200/authors/book/1?parent=2 -d '{
"name": "Revelation Space",
"genre": "scifi",
"publisher": "penguin"
}'
好的,謝謝你解釋路由如何在父/子關係中工作。 – Robin
另外,我已經找到了你鏈接的要點,但是我希望不必手動完成:'Comment.tire.index.store(comment3,:parent => 1)'。輪胎的udpate_index方法不支持它是很可悲的。 – Robin
非常感謝,我設法讓它工作!雖然我只設法使它與過濾器一起工作,而不是查詢:http://stackoverflow.com/questions/22332740/elasticsearch-query-with-a-parent-child-relationship-failing如果你想看看...理想情況下,我想要一個過濾布爾查詢我想。 – Robin