# Search Nested documents

**URL:** <https://discuss.elastic.co/t/search-nested-documents/6784>\
**Category:** Elasticsearch\
**Created:** [February 22, 2012, 11:56am UTC](https://discuss.elastic.co/t/search-nested-documents/6784 "2012-02-22T11:56:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ridvan\_Gyundogan](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@Ridvan\_Gyundogan](https://discuss.elastic.co/u/Ridvan_Gyundogan)\
**Post date:** [February 22, 2012, 11:56am UTC](https://discuss.elastic.co/t/search-nested-documents/6784/1 "2012-02-22T11:56:47Z")

</div>

Hi All,  
I saw lot of messages in the group about "parent/child" and "nested",  
but am still unable to solve my issue.

I am holding nested type as shown here:  
[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html)  
The main reason for this is to make some facets on the nested type  
"type1.obj1".

Some times though I need to query only the nested type "type1.obj1"  
and to extract it's \_source. I tried with:  
#curl -XGET [http://localhost:9200/giftsplusindex/type1.obj/\_search](http://localhost:9200/giftsplusindex/type1.obj/_search)  
but it didn't work.

Then I tried with the query bellow, but it still returns the type1  
documents with all the type1.obj1 documents inside and not only obj1  
documents:  
#curl -XGET [http://localhost:9200/giftsplusindex/type1/\_search?pretty=true](http://localhost:9200/giftsplusindex/type1/_search?pretty=true)  
-d '  
{  
"query": {  
"nested": {  
"path": "obj1",  
"query": {  
"match\_all" : { }  
}  
}  
},  
"size": 10,  
"from": 0  
}'

I suppose this will work with "parent/child" but in this case I can  
not make facets on the child I think?

I guess I am doing some design error.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 26, 2012, 9:48am UTC](https://discuss.elastic.co/t/search-nested-documents/6784/2 "2012-02-26T09:48:46Z")

</div>

You want to get just the nested document source? If so, you can't, you get back the full document you indexed back.

On Wednesday, February 22, 2012 at 1:56 PM, Ridvan Gyundogan wrote:

> Hi All,  
> I saw lot of messages in the group about "parent/child" and "nested",  
> but am still unable to solve my issue.
> 
> I am holding nested type as shown here:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html)  
> The main reason for this is to make some facets on the nested type  
> "type1.obj1".
> 
> Some times though I need to query only the nested type "type1.obj1"  
> and to extract it's \_source. I tried with:  
> #curl -XGET [http://localhost:9200/giftsplusindex/type1.obj/\_search](http://localhost:9200/giftsplusindex/type1.obj/_search)  
> but it didn't work.
> 
> Then I tried with the query bellow, but it still returns the type1  
> documents with all the type1.obj1 documents inside and not only obj1  
> documents:  
> #curl -XGET [http://localhost:9200/giftsplusindex/type1/\_search?pretty=true](http://localhost:9200/giftsplusindex/type1/_search?pretty=true)  
> -d '  
> {  
> "query": {  
> "nested": {  
> "path": "obj1",  
> "query": {  
> "match\_all" : { }  
> }  
> }  
> },  
> "size": 10,  
> "from": 0  
> }'
> 
> I suppose this will work with "parent/child" but in this case I can  
> not make facets on the child I think?
> 
> I guess I am doing some design error.

---

<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:38am UTC](https://discuss.elastic.co/t/search-nested-documents/6784/3 "2017-07-06T03:38:16Z")

</div>


