# \[Newbie\] facet search on nested documents failing

**URL:** <https://discuss.elastic.co/t/newbie-facet-search-on-nested-documents-failing/5799>\
**Category:** Elasticsearch\
**Created:** [November 7, 2011, 4:06pm UTC](https://discuss.elastic.co/t/newbie-facet-search-on-nested-documents-failing/5799 "2011-11-07T16:06:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [November 7, 2011, 4:06pm UTC](https://discuss.elastic.co/t/newbie-facet-search-on-nested-documents-failing/5799/1 "2011-11-07T16:06:12Z")

</div>

I followed the following links in following wiki's to try out facet search  
on nested documents but failed with the following error

WIKI - [http://www.elasticsearch.org/guide/reference/mapping/nested-type.html](http://www.elasticsearch.org/guide/reference/mapping/nested-type.html),  
[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html)

I am trying out this for sometime without any luck or understanding the  
nature of the problem.

Please help me out of this issue .

vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -XPOST  
localhost:9200/kerala -d @createIndex ; echo  
{"ok":true,"acknowledged":true}  
vineeth@vineeth-XPS-L501X:~/elasticSearch$ cat createIndex  
{  
"public" : {  
"properties" : {  
"obj1" : {  
"type" : "nested"  
}  
}  
}  
}  
vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -XPOST  
localhost:9200/kerala/public -d @sampleDoc ; echo  
{"ok":true,"\_index":"kerala","\_type":"public","\_id":"hAqFUQlQQzSnTk\_3VDr6oQ","\_version":1}  
vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -XPOST  
localhost:9200/kerala/public -d @sampleDoc ; echo  
{"ok":true,"\_index":"kerala","\_type":"public","\_id":"8gEPfNhFQ3ao6nhKvLfXlw","\_version":1}  
vineeth@vineeth-XPS-L501X:~/elasticSearch$ cat sampleDoc  
{  
"obj1" : [  
{  
"name" : "blue",  
"count" : 4  
},  
{  
"name" : "green",  
"count" : 6  
}  
]  
}  
vineeth@vineeth-XPS-L501X:~/elasticSearch$ cat query  
{  
"nested" : {  
"path" : "obj1",  
"score\_mode" : "avg",  
"query" : {  
"bool" : {  
"must" : [  
{  
"text" : {"obj1.name" : "blue"}  
},  
{  
"range" : {"obj1.count" : {"gt" : 5}}  
}  
]  
}  
}  
}  
}

vineeth@vineeth-XPS-L501X:~/elasticSearch$ curl -XPOST  
localhost:9200/kerala/public/\_search -d @query  
{"error":"SearchPhaseExecutionException[Failed to execute phase [query],  
total failure; shardFailures {[wyPXb3DjT-WLKRKFTsR5uA][kerala][4]:  
RemoteTransportException[[DJ][inet[/192.168.1.2:9302]][search/phase/query]];  
nested: SearchParseException[[kerala][4]: from[-1],size[-1]: Parse Failure  
[Failed to parse source [{ "nested" : { "path" :  
"obj1", "score\_mode" : "avg", "query" : {  
"bool" : { "must" : [  
{ "text" : {"obj1.name" :  
"blue"} }, {  
"range" : {"obj1.count" : {"gt" : 5}}  
} ] } } }}]]]; nested:  
SearchParseException[[kerala][4]: from[-1],size[-1]: Parse Failure [No  
parser for element [nested]]]; }{[Nk3z-jbdSNGdOgOUiA4UdQ][kerala][0]:  
RemoteTransportException[[Redwing][inet[/192.168.1.2:9301]][search/phase/query]];  
nested: SearchParseException[[kerala][0]: from[-1],size[-1]: Parse Failure  
[Failed to parse source [{ "nested" : { "path" :  
"obj1", "score\_mode" : "avg", "query" : {  
"bool" : { "must" : [  
{ "text" : {"obj1.name" :  
"blue"} }, {  
"range" : {"obj1.count" : {"gt" : 5}}  
} ] } } }}]]]; nested:  
SearchParseException[[kerala][0]: from[-1],size[-1]: Parse Failure [No  
parser for element [nested]]]; }{[wyPXb3DjT-WLKRKFTsR5uA][kerala][3]:  
RemoteTransportException[[DJ][inet[/192.168.1.2:9302]][search/phase/query]];  
nested: SearchParseException[[kerala][3]: from[-1],size[-1]: Parse Failure  
[Failed to parse source [{ "nested" : { "path" :  
"obj1", "score\_mode" : "avg", "query" : {  
"bool" : { "must" : [  
{ "text" : {"obj1.name" :  
"blue"} }, {  
"range" : {"obj1.count" : {"gt" : 5}}  
} ] } } }}]]]; nested:  
SearchParseException[[kerala][3]: from[-1],size[-1]: Parse Failure [No  
parser for element [nested]]]; }{[SJhaK1cERxuctG6ZUM4JMw][kerala][1]:  
SearchParseException[[kerala][1]: from[-1],size[-1]: Parse Failure [Failed  
to parse source [{ "nested" : { "path" : "obj1",  
"score\_mode" : "avg", "query" : { "bool" :  
{ "must" : [ {  
"text" : {"obj1.name" : "blue"}  
}, { "range" : {"obj1.count"  
: {"gt" : 5}} } ] }  
} }}]]]; nested: SearchParseException[[kerala][1]: from[-1],size[-1]:  
Parse Failure [No parser for element [nested]]];  
}{[wyPXb3DjT-WLKRKFTsR5uA][kerala][2]:  
RemoteTransportException[[DJ][inet[/192.168.1.2:9302]][search/phase/query]];  
nested: SearchParseException[[kerala][2]: from[-1],size[-1]: Parse Failure  
[Failed to parse source [{ "nested" : { "path" :  
"obj1", "score\_mode" : "avg", "query" : {  
"bool" : { "must" : [  
{ "text" : {"obj1.name" :  
"blue"} }, {  
"range" : {"obj1.count" : {"gt" : 5}}  
} ] } } }}]]]; nested:  
SearchParseException[[kerala][2]: from[-1],size[-1]: Parse Failure [No  
parser for element [nested]]]; }]","status":500}

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [November 7, 2011, 6:53pm UTC](https://discuss.elastic.co/t/newbie-facet-search-on-nested-documents-failing/5799/2 "2011-11-07T18:53:39Z")

</div>

Hi Vineeth

It is much easier to read your code if they are gisted, not included in  
the email.

Have a look at [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help) for some advice about  
how to ask questions in a way that people are likely to answer them

> {  
> "nested" : {  
> "path" : "obj1",  
> "score\_mode" : "avg",  
> "query" : {  
> "bool" : {  
> "must" : [  
> {  
> "text" : {"obj1.name" : "blue"}  
> },  
> {  
> "range" : {"obj1.count" : {"gt" : 5}}  
> }  
> ]  
> }  
> }  
> }  
> }

You are missing a top level 'query' param. So the 'nested' element  
should be wrapped in { query: { nested: ... }}

clint

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [November 8, 2011, 2:42am UTC](https://discuss.elastic.co/t/newbie-facet-search-on-nested-documents-failing/5799/3 "2011-11-08T02:42:26Z")

</div>

Thanks Clinton ,

One of the issues were that , i will strictly follow the guidelines when i  
post another question.

One of the issues were that i didn't use \_mapping to apply obj1 as nested.

Thanks  
Vineeth

On Tue, Nov 8, 2011 at 12:23 AM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:

> Hi Vineeth
> 
> It is much easier to read your code if they are gisted, not included in  
> the email.
> 
> Have a look at [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help) for some advice about  
> how to ask questions in a way that people are likely to answer them
> 
> > {  
> > "nested" : {  
> > "path" : "obj1",  
> > "score\_mode" : "avg",  
> > "query" : {  
> > "bool" : {  
> > "must" : [  
> > {  
> > "text" : {"obj1.name" : "blue"}  
> > },  
> > {  
> > "range" : {"obj1.count" : {"gt" : 5}}  
> > }  
> > ]  
> > }  
> > }  
> > }  
> > }
> 
> You are missing a top level 'query' param. So the 'nested' element  
> should be wrapped in { query: { nested: ... }}
> 
> clint

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [November 8, 2011, 2:58am UTC](https://discuss.elastic.co/t/newbie-facet-search-on-nested-documents-failing/5799/4 "2011-11-08T02:58:42Z")

</div>

oops sorry for the weired text 🙂  
What i meant was that

"i will strictly follow the guidelines when i post another question.

One of the issues were that i didn't use \_mapping to apply obj1 as nested."

On Tue, Nov 8, 2011 at 8:12 AM, Vineeth Mohan [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com)wrote:

> Thanks Clinton ,
> 
> One of the issues were that , i will strictly follow the guidelines when  
> i post another question.
> 
> One of the issues were that i didn't use \_mapping to apply obj1 as nested.
> 
> Thanks  
> Vineeth
> 
> On Tue, Nov 8, 2011 at 12:23 AM, Clinton Gormley [clint@traveljury.com](mailto:clint@traveljury.com)wrote:
> 
> > Hi Vineeth
> > 
> > It is much easier to read your code if they are gisted, not included in  
> > the email.
> > 
> > Have a look at [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help) for some advice about  
> > how to ask questions in a way that people are likely to answer them
> > 
> > > {  
> > > "nested" : {  
> > > "path" : "obj1",  
> > > "score\_mode" : "avg",  
> > > "query" : {  
> > > "bool" : {  
> > > "must" : [  
> > > {  
> > > "text" : {"obj1.name" : "blue"}  
> > > },  
> > > {  
> > > "range" : {"obj1.count" : {"gt" : 5}}  
> > > }  
> > > ]  
> > > }  
> > > }  
> > > }  
> > > }
> > 
> > You are missing a top level 'query' param. So the 'nested' element  
> > should be wrapped in { query: { nested: ... }}
> > 
> > clint

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [November 8, 2011, 10:40am UTC](https://discuss.elastic.co/t/newbie-facet-search-on-nested-documents-failing/5799/5 "2011-11-08T10:40:53Z")

</div>

On Tue, 2011-11-08 at 08:28 +0530, Vineeth Mohan wrote:

> oops sorry for the weired text 🙂  
> What i meant was that
> 
> "i will strictly follow the guidelines when i post another question.

🙂

Just to say: I wasn't saying "bad bad boy!", but rather, if the code is  
easy to read (ie gisted) then it is more likely that people will read  
it, and thus answer.

glad you found the solution

c

> One of the issues were that i didn't use \_mapping to apply obj1 as  
> nested."
> 
> On Tue, Nov 8, 2011 at 8:12 AM, Vineeth Mohan  
> [vineethmohan@algotree.com](mailto:vineethmohan@algotree.com) wrote:  
> Thanks Clinton ,
> 
> ```
> One of the issues were that , i will strictly follow the
> guidelines when i post another question.
>     
> One of the issues were that i didn't use _mapping to apply
> obj1 as nested.
>     
> Thanks
> Vineeth
>     
>     
>     
> On Tue, Nov 8, 2011 at 12:23 AM, Clinton Gormley
> <clint@traveljury.com> wrote:
> Hi Vineeth
>             
> It is much easier to read your code if they are
> gisted, not included in
> the email.
>             
> Have a look at http://www.elasticsearch.org/help for
> some advice about
> how to ask questions in a way that people are likely
> to answer them
>             
> > {
> > "nested" : {
> > "path" : "obj1",
> > "score_mode" : "avg",
> > "query" : {
> > "bool" : {
> > "must" : [
> > {
> > "text" : {"obj1.name" :
> "blue"}
> > },
> > {
> > "range" : {"obj1.count" :
> {"gt" : 5}}
> > }
> > ]
> > }
> > }
> > }
> > }
>             
>             
> You are missing a top level 'query' param. So the
> 'nested' element
> should be wrapped in { query: { nested: ... }}
>             
> clint
> 
> ```

---

<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:49am UTC](https://discuss.elastic.co/t/newbie-facet-search-on-nested-documents-failing/5799/6 "2017-07-06T03:49:35Z")

</div>


