# Return multiple parent documents for each nested object match

**URL:** <https://discuss.elastic.co/t/return-multiple-parent-documents-for-each-nested-object-match/307873>\
**Category:** Elasticsearch\
**Created:** [June 22, 2022, 11:59am UTC](https://discuss.elastic.co/t/return-multiple-parent-documents-for-each-nested-object-match/307873 "2022-06-22T11:59:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgurusam](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@dgurusam](https://discuss.elastic.co/u/dgurusam)\
**Post date:** [June 22, 2022, 11:59am UTC](https://discuss.elastic.co/t/return-multiple-parent-documents-for-each-nested-object-match/307873/1 "2022-06-22T11:59:52Z")

</div>

Hi All,  
I have an index which contains a nested object. I would like to return multiple parent documents for each object matched in the nested object.

For example:

Index Details:

```auto
  "settings": {
       "number_of_shards": 1
   },
   "mappings": {
       "_doc": {
           "properties": {
               "OrderId": {
                   "type": "text"
               },
               "Product": {
                   "type": "nested",
                   "properties": {
                       "ProductId": {
                           "type": "long"
                       },
                       "ProductName": {
                           "type": "text"
                       }
                   }
               }
           }
       }
   }
}

{
"orderId" :1,
"Product: :[
{
"ProductId" : 1,
"ProductName" : "LG1 TV",
"Quantity" : 2 
},
{
"ProductId" : 2,
"ProductName" : "Sony1 TV",
"Quantity" : 2 
},
{
"ProductId" : 1,
"ProductName" : "LG1 TV",
"Quantity" : 5
},
]
}

{   
 "query": {
   "nested": {
     "path": "Product",
     "query": {
       "match": {"Product.Productname" : "Public1"}
     }
   }
 }
}

```

Now i want to return order details that matched LG1 TV. I would like to have two rows in this case in the output because there are two nested objects have a match.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 20, 2022, 11:59am UTC](https://discuss.elastic.co/t/return-multiple-parent-documents-for-each-nested-object-match/307873/2 "2022-07-20T11:59:52Z")

</div>

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