# How to one result when search nested?

**URL:** <https://discuss.elastic.co/t/how-to-one-result-when-search-nested/9749>\
**Category:** Elasticsearch\
**Created:** [November 17, 2012, 9:43am UTC](https://discuss.elastic.co/t/how-to-one-result-when-search-nested/9749 "2012-11-17T09:43:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![softtech\_Wonder](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@softtech\_Wonder](https://discuss.elastic.co/u/softtech_Wonder)\
**Post date:** [November 17, 2012, 9:43am UTC](https://discuss.elastic.co/t/how-to-one-result-when-search-nested/9749/1 "2012-11-17T09:43:57Z")

</div>

this is data  
{  
'firstname' :'Nicolas'  
'lastname' :'Ippolito'  
'books' :array  
{  
0 :array  
{  
'name' :php,  
'rating':3  
}  
1 :array  
{  
'name' :'nodejs',  
'rating':5,  
},  
2 :array  
{  
'name' :'guitar',  
'rating':3,  
}  
}  
}  
I want result data if books.rating is "Max" and only one nested  
example result I want  
{  
'firstname' :'Nicolas'  
'lastname' :'Ippolito'  
'books' :array  
{  
0 :array  
{  
'name' :'nodejs',  
'rating':5,  
},  
}  
}

--

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [November 17, 2012, 1:46pm UTC](https://discuss.elastic.co/t/how-to-one-result-when-search-nested/9749/2 "2012-11-17T13:46:27Z")

</div>

Hi,

You mean, when a search hits a document, you want ES only to return  
parts of that document?

If so, I'm not sure how you can do this other than at client side. Or,  
by changing your data structure. For example, you might want to use  
parent-child and search for what you want in the children, then use  
the has\_parent[0] query to search for what you want in the parent. In  
this case Elasticsearch would return only the matching children. And  
you can fetch their parents at client-side using the Multi Get API[1]

[0] [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/has-parent-query.html)  
[1] [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/reference/api/multi-get.html)

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Sat, Nov 17, 2012 at 11:43 AM, softtech Wonder  
[wondersofttech@gmail.com](mailto:wondersofttech@gmail.com) wrote:

> this is data  
> {  
> 'firstname' :'Nicolas'  
> 'lastname' :'Ippolito'  
> 'books' :array  
> {  
> 0 :array  
> {  
> 'name' :php,  
> 'rating':3  
> }  
> 1 :array  
> {  
> 'name' :'nodejs',  
> 'rating':5,  
> },  
> 2 :array  
> {  
> 'name' :'guitar',  
> 'rating':3,  
> }  
> }  
> }  
> I want result data if books.rating is "Max" and only one nested  
> example result I want  
> {  
> 'firstname' :'Nicolas'  
> 'lastname' :'Ippolito'  
> 'books' :array  
> {  
> 0 :array  
> {  
> 'name' :'nodejs',  
> 'rating':5,  
> },  
> }  
> }
> 
> --

--

---

<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 6, 2017, 3:03am UTC](https://discuss.elastic.co/t/how-to-one-result-when-search-nested/9749/3 "2017-07-06T03:03:51Z")

</div>


