elasticsearch - Include Child Documents in Elastic Search Query -


i trying include child documents query elastic search, cannot figure out. have entity called posts has optional parent support parent child hierarchy. hoping query on parent or top level items , include top child results, preventing doing multiple calls elastic search.

mapping

{   "mappings": {     "post": {       "_parent": {         "type": "post"       },       "id": { "type": "integer"},       "text": { "type": "string"},       "parent_id": { "type": "integer"},       "rank": { "type": "integer"}     }   } } 

desired response

{   "hits": {     "total": 10,     "max_score": null,     "hits": [       {         "id": 1,         "text": "test",         "parent_id": null,         "rank": 10,         "topresponse": {           "id": 2,           "text": "test response",           "parent_id": null,           "rank": 4         }       },       {         "id": 1,         "text": "test 2",         "parent_id": null,         "rank": 8,         "topresponse": {           "id": 2,           "text": "test response",           "parent_id": null,           "rank": 3         }       },       {         "id": 1,         "text": "test 3",         "parent_id": null,         "rank": 6,         "topresponse": {           "id": 2,           "text": "test response",           "parent_id": null,           "rank": 1         }       }     ]   } } 


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -