Elastic join query not returning correct result


(Chetan Vartak) #1

I have data in elastic with parent-child relationship. But both "has_child" and "has_parent" queries is missing few inner hits.

Query with "has_child" is returning 2 doc. But there are 3 doc. If I remove the "has_child" part of query, it returns 3 doc. But I know that the missing doc also have a child -
{"_source":false,"query":{"bool":{"must":[{"terms":{"order_doc_type":["order_line"]}},{"terms":{"channel_order_id":["mf806561363"]}},{"has_child":{"type":"shipment_line","query":{"match_all":{}},"inner_hits":{"size":10,"_source":false}}}]}}}

I have the same result when I look with "has_parent".

I can verify that the parent-child relationship exists for the missing doc -
This 2 is returned with the above query -
GET perfectorder_v2/order/mf806561363-1-sg830139117?_source=false&routing=mf806561363-1
GET perfectorder_v2/order/mf806561363-2-sg830139117?_source=false&routing=mf806561363-2

And this one not
GET perfectorder_v2/order/mf806561363-3-sg830139117?_source=false&routing=mf806561363-3

I can provide more details... but here few questions -

  1. Is having "-" in the _id have any impact?
  2. My mapping looks fine... but please let me know if this could be an issue

{
"perfectorder_v2": {
"mappings": {
"order": {
"properties": {
"doc_type": {
"type": "join",
"eager_global_ordinals": true,
"relations": {
"order_header": "order_line",
"order_line": [
"backorder_line",
"shipment_line",
"stop_shipment_line",
"cancel_line",
"return_line",
"release_line"
]
}
},
"order_doc_type": {
"type": "keyword"
},

  1. I'm using ES 6.1.1 right now

(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.