私は壮大な子供を探している間、弾性検索のいくつかの奇妙な動作に直面しています。私の孫は親文書ごとにそれぞれを認識しません。親の子供たちを返すために弾性検索をすると、すべてのヒットを返します。それから、孫がいる子供たちを私に返すように頼むと、私は間違った結果を得ます。いくつかの時間私はヒットまたはそれ以下を取得します。しかし、私がグランド・チャイルドのルーティングと親IDを確認すると、彼らは彼らの親に存在することがわかりました。しかし、なぜ私は間違った結果を得ているのか理解できません。あなたの誰かがこの種の問題に遭遇しましたか? 。ElasticSearch:孫/子/親の関係が正しく機能していない
PUT/test_index
:私は三度私のコードをチェックし、私はこのエラーを再現するために、あなたに手順をお見せしましょう :-(いずれかのタイプのエラーが見つかりませんでした ここは私のマッピングです
{ "mappings":{ "parentDoc":{ "properties":{ "id":{ "type":"integer" }, "name":{ "type":"text" } } }, "childDoc": { "_parent": { "type": "parentDoc" }, "properties":{ "id":{ "type":"integer" }, "name":{ "type":"text" }, "contact": { "type":"text" } } }, "grandChildDoc": { "_parent": { "type": "childDoc" }, "properties":{ "id":{ "type":"integer" }, "description":{ "type":"text" } } } } }
インデックスparentDoc:
PUT/test_index/parentDoc/1
{
"pdId":1,
"name": "First parentDoc"
}
PUT/test_index/parentDoc/2
{
"pdId":2,
"name": "Second parentDoc"
}
インデックスchildDoc:
PUT/test_index/childDoc/10?親= 1
?PUT/test_index/childDoc/101親= 1
{
"cdId":101,
"name": "Second childDoc",
"contact" : "+XX0000000111"
}
PUT/test_index/childDoc/20親= 2
{
"cdId":20,
"name": "Third childDoc",
"contact" : "+XX0011100000"
}
インデックスgrandChildDoc:
PUT/test_index/grandChildDoc/100?親= 10
{
"gcdId":100,
"name": "First grandChildDoc"
}
PUT/test_index/grandChildDoc/200?親= 10
{
"gcdId":200,
"name": "Second grandChildDoc"
}
PUT/test_index/grandChildDoc/300?私は私にchildDocを持っているものをparentDocを表示するように弾性検索を要求したとき、親は= 20
{
"gcdId":300,
"name": "Third grandChildDoc"
}
は今、それが返されます。 POST/test_index/parentDoc/_search
{
"query": {
"has_child": {
"type": "childDoc",
"query": {
"match_all": {}
}
}
}
}
結果:(これは問題ありません!)
01私は私にgrandChildDocを持っているものをchildDocを表示するelasticsearchを頼むときは今、それが返されます。 POST/test_index/childDoc/_search
{
"query": {
"has_child": {
"type": "grandChildDoc",
"query": {
"match_all": {}
}
}
}
}
結果:(ここでは、ヒットの一部が欠落していることがわかります。例えば、のidとの子ドックがあります。
{
"took": 7,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "test_index",
"_type": "childDoc",
"_id": "20",
"_score": 1,
"_routing": "2",
"_parent": "2",
"_source": {
"cdId": 20,
"name": "Third childDoc",
"contact": "+XX0011100000"
}
}
]
}
}
私は何をしているのですか?それともバグですか?任意の回避策または解決策???
[注:私はelasticsearch V5.4を使用しています]