# Viewing nested objects

**URL:** https://discuss.elastic.co/t/viewing-nested-objects/9418
**Category:** Elasticsearch
**Created:** [October 19, 2012, 12:20am UTC](https://discuss.elastic.co/t/viewing-nested-objects/9418 "2012-10-19T00:20:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![phill](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@phill](https://discuss.elastic.co/u/phill)
#### Post date: [October 19, 2012, 12:20am UTC](https://discuss.elastic.co/t/viewing-nested-objects/9418/1 "2012-10-19T00:20:46Z")

</div>

I built a nested object within another object, but I'm still working out  
how to get the queries right.  
When I was 1st working with a child object, I could use the head  
application and query on the child objects separately.  
But I don't know the name of the nested object  
(Note I set include\_in\_parent of my nested object to false)

Is there a way to use the REST API to query just the nested objects?  
[http://localhost:9200/myindex/](http://localhost:9200/myindex/)/\_search ....

Do the nested objects have a predictable name based on the names given  
in the mapping?  
anObject : {  
dynamic: "strict"  
,properties : {  
"name": { type:"string", store:1,  
index:"analyzed", omit\_norms:0, omit\_term\_freq\_positions:0,  
term\_vector:"yes" }  
, "Codes": {  
type:"nested"  
,dynamic: "strict"  
,"include\_in\_parent" : "false"  
,properties: {  
"thing1" : { type:"string", store:1,  
index:"analyzed", omit\_norms:0, omit\_term\_freq\_positions:0,  
term\_vector:"yes" }  
"thing2" : { type:"string", store:1,  
index:"analyzed", omit\_norms:0, omit\_term\_freq\_positions:0,  
term\_vector:"yes" }  
}  
}

-Paul

--

---

<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: [October 21, 2012, 1:01am UTC](https://discuss.elastic.co/t/viewing-nested-objects/9418/2 "2012-10-21T01:01:44Z")

</div>

They have a predictable name, but, queries on nested objects _must_ be wrapped in a nested query (or filter). If you still want to use the URI option to query it, you can build the search request full "body", and provide it in a "source" parameter.

On Oct 19, 2012, at 2:22 AM, P. Hill [parehill1@gmail.com](mailto:parehill1@gmail.com) wrote:

> I built a nested object within another object, but I'm still working out how to get the queries right.  
> When I was 1st working with a child object, I could use the head application and query on the child objects separately.  
> But I don't know the name of the nested object  
> (Note I set include\_in\_parent of my nested object to false)
> 
> Is there a way to use the REST API to query just the nested objects?  
> [http://localhost:9200/myindex/](http://localhost:9200/myindex/)/\_search ....
> 
> Do the nested objects have a predictable name based on the names given in the mapping?  
> anObject : {  
> dynamic: "strict"  
> ,properties : {  
> "name": { type:"string", store:1, index:"analyzed", omit\_norms:0, omit\_term\_freq\_positions:0, term\_vector:"yes" }  
> , "Codes": {  
> type:"nested"  
> ,dynamic: "strict"  
> ,"include\_in\_parent" : "false"  
> ,properties: {  
> "thing1" : { type:"string", store:1, index:"analyzed", omit\_norms:0, omit\_term\_freq\_positions:0, term\_vector:"yes" }  
> "thing2" : { type:"string", store:1, index:"analyzed", omit\_norms:0, omit\_term\_freq\_positions:0, term\_vector:"yes" }  
> }  
> }
> 
> -Paul
> 
> --

--

---

<div class="post-metadata">

### Author: ![phill](https://avatars.discourse-cdn.com/v4/letter/p/779978/32.png) [@phill](https://discuss.elastic.co/u/phill)
#### Post date: [October 30, 2012, 4:56am UTC](https://discuss.elastic.co/t/viewing-nested-objects/9418/3 "2012-10-30T04:56:10Z")

</div>

I don't understand.

If nested queries must be wrapped, what does it matter that I want to  
use it? To me, your statement of "must" makes it sound impossible to  
only query the nested objects.  
The search I wanted to build was for debugging just to check I'm doing  
the search right I can't image any other uses for it.

You said provide "it"? I'm guessing you mean the name, but you didn't  
tell me the predictable name of a nested object. You say I should put  
this name in the "source" parameter, but the search UI doesn't seem to  
have a "source" parameter in the URI, so again I'm confused. Did you  
mean in the source when indexing? I gave the nested object a name when  
indexing, but I don't know how that maps to what to say when searching.

What is the predictable name?  
Example I have "MyOuter" with a nested object "MyNested".  
Define "_must_ be nested"?  
Where is this source parameter?

-Paul

On 10/20/2012 6:01 PM, [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> They have a predictable name, but, queries on nested objects _must_ be wrapped in a nested query (or filter). If you still want to use the URI option to query it, you can build the search request full "body", and provide it in a "source" parameter.
> 
> On Oct 19, 2012, at 2:22 AM, P. Hill[parehill1@gmail.com](mailto:parehill1@gmail.com) wrote:
> 
> > I built a nested object within another object, but I'm still working out how to get the queries right.  
> > When I was 1st working with a child object, I could use the head application and query on the child objects separately.  
> > But I don't know the name of the nested object  
> > (Note I set include\_in\_parent of my nested object to false)
> > 
> > Is there a way to use the REST API to query just the nested objects?  
> > [http://localhost:9200/myindex/](http://localhost:9200/myindex/)/\_search ....
> > 
> > Do the nested objects have a predictable name based on the names given in the mapping?

--

---

<div class="post-metadata">

### Author: ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)
#### Post date: [October 30, 2012, 8:56am UTC](https://discuss.elastic.co/t/viewing-nested-objects/9418/4 "2012-10-30T08:56:46Z")

</div>

Hi Paul,

On Tue, Oct 30, 2012 at 5:56 AM, P.Hill [parehill1@gmail.com](mailto:parehill1@gmail.com) wrote:

> I don't understand.
> 
> If nested queries must be wrapped, what does it matter that I want to use  
> it? To me, your statement of "must" makes it sound impossible to only query  
> the nested objects.  
> The search I wanted to build was for debugging just to check I'm doing the  
> search right I can't image any other uses for it.
> 
> You said provide "it"? I'm guessing you mean the name, but you didn't  
> tell me the predictable name of a nested object. You say I should put  
> this name in the "source" parameter, but the search UI doesn't seem to have  
> a "source" parameter in the URI, so again I'm confused. Did you mean in  
> the source when indexing? I gave the nested object a name when indexing,  
> but I don't know how that maps to what to say when searching.
> 
> What is the predictable name?  
> Example I have "MyOuter" with a nested object "MyNested".

In this case I _think_ internal type name for the nested objects will be  
"\_\_MyNested". But, keep in mind that querying against nested type will not  
yield any data. AFAIK ES does not allow you to do that (and there are good  
reasons not to let users do it, among others that would mean that nested  
objects would have to be exposed along with some kind of document ID and  
that could create false impression that you can freely manipulate/update  
individual nested documents, which is not currently possible via ES API.).

> Define "_must_ be nested"?

The query that involves nested object query (or filter) yields parent  
documents only. That's all about it.  
So the query or filter is supposed to include "nested : {...}" clause. That  
is the only way how you can create query/filter that is run against nested  
documents and yields list of parent documents.

> Where is this source parameter?

I think what Shay was referring to was "source" URL parameter as described  
here: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/) (see "Request body  
in query string").

HTH,  
Lukas

> -Paul
> 
> On 10/20/2012 6:01 PM, [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> 
> > They have a predictable name, but, queries on nested objects _must_ be  
> > wrapped in a nested query (or filter). If you still want to use the URI  
> > option to query it, you can build the search request full "body", and  
> > provide it in a "source" parameter.
> > 
> > On Oct 19, 2012, at 2:22 AM, P. Hill[parehill1@gmail.com](mailto:parehill1@gmail.com) wrote:
> > 
> > I built a nested object within another object, but I'm still working out
> > 
> > > how to get the queries right.  
> > > When I was 1st working with a child object, I could use the head  
> > > application and query on the child objects separately.  
> > > But I don't know the name of the nested object  
> > > (Note I set include\_in\_parent of my nested object to false)
> > > 
> > > Is there a way to use the REST API to query just the nested objects?  
> > > [http://localhost:9200/myindex/](http://localhost:9200/myindex/)\*\*/\_search ....
> > > 
> > > Do the nested objects have a predictable name based on the names given  
> > > in the mapping?
> 
> --

--

---

<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:06am UTC](https://discuss.elastic.co/t/viewing-nested-objects/9418/5 "2017-07-06T03:06:51Z")

</div>


