# Nested filter query giving error

**URL:** <https://discuss.elastic.co/t/nested-filter-query-giving-error/20234>\
**Category:** Elasticsearch\
**Created:** [October 14, 2014, 10:00am UTC](https://discuss.elastic.co/t/nested-filter-query-giving-error/20234 "2014-10-14T10:00:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shekhar\_chauhan](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@shekhar\_chauhan](https://discuss.elastic.co/u/shekhar_chauhan)\
**Post date:** [October 14, 2014, 10:00am UTC](https://discuss.elastic.co/t/nested-filter-query-giving-error/20234/1 "2014-10-14T10:00:44Z")

</div>

Hi all,  
I am new to elastic search.I am using nested filter query.this query is  
giving error "failed to find nested object under path [itemResults]]".

my document structure is -

{  
"\_id": "inspectionresults-07d864fd-76ec-427a-a1c6-b70e420ce3d8",  
"\_rev": "12-64c44ddcfcd477dfa86cdb9d3c659748",  
"sectionResults": [

```
   {
       "SectionName": "More Details",
       "itemResults": [
           
           {
               "InspectionItem": "Launch Month",
               "ItemInfo": ""
               
           }
       ]
   }

```

]  
}

and my query is -

{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"nested": {  
"path": "itemResults",  
"filter": {  
"bool": {  
"must": [  
{  
"term": {  
"itemResults.InspectionItem": "Launch Month"  
}  
}  
]  
}  
}  
}  
}  
}  
}  
}

Error - "failed to find nested object under path [itemResults]]"

But as you are seeing in document itemResults is already nested object.  
Please reply.  
Thanks in advance,

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a38b570f-64ac-44e6-8424-59ffb6bafa52%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a38b570f-64ac-44e6-8424-59ffb6bafa52%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [October 14, 2014, 11:21am UTC](https://discuss.elastic.co/t/nested-filter-query-giving-error/20234/2 "2014-10-14T11:21:23Z")

</div>

Hi,

elasticsearc has two ways to index inner json documents, one is called  
"object"[0] (which is the default) and the other is called "nested"[1]. You  
need to have the `itemResults` field mapped as `nested` in your mappings.

[0]

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

[1]

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Tue, Oct 14, 2014 at 12:00 PM, shekhar chauhan \<  
[shekharchauhan91@gmail.com](mailto:shekharchauhan91@gmail.com)\> wrote:

> Hi all,  
> I am new to Elasticsearch.I am using nested filter query.this query is  
> giving error "failed to find nested object under path [itemResults]]".
> 
> my document structure is -
> 
> {  
> "\_id": "inspectionresults-07d864fd-76ec-427a-a1c6-b70e420ce3d8",  
> "\_rev": "12-64c44ddcfcd477dfa86cdb9d3c659748",  
> "sectionResults": [
> 
> ```
> {
> "SectionName": "More Details",
> "itemResults": [
> 
> {
> "InspectionItem": "Launch Month",
> "ItemInfo": ""
> 
> }
> ]
> }
> 
> ```
> 
> ]  
> }
> 
> and my query is -
> 
> {  
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "nested": {  
> "path": "itemResults",  
> "filter": {  
> "bool": {  
> "must": [  
> {  
> "term": {  
> "itemResults.InspectionItem": "Launch Month"  
> }  
> }  
> ]  
> }  
> }  
> }  
> }  
> }  
> }  
> }
> 
> Error - "failed to find nested object under path [itemResults]]"
> 
> But as you are seeing in document itemResults is already nested object.  
> Please reply.  
> Thanks in advance,
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/a38b570f-64ac-44e6-8424-59ffb6bafa52%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a38b570f-64ac-44e6-8424-59ffb6bafa52%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/a38b570f-64ac-44e6-8424-59ffb6bafa52%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a38b570f-64ac-44e6-8424-59ffb6bafa52%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j41Ewx-Kui\_bxtjDotnktC7a29Q3bw2umH\_7qERQ9MVhw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j41Ewx-Kui_bxtjDotnktC7a29Q3bw2umH_7qERQ9MVhw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![shekhar\_chauhan](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@shekhar\_chauhan](https://discuss.elastic.co/u/shekhar_chauhan)\
**Post date:** [October 15, 2014, 7:13am UTC](https://discuss.elastic.co/t/nested-filter-query-giving-error/20234/3 "2014-10-15T07:13:49Z")

</div>

Hi Adrien,  
Thanks for your reply.but Now I am facing a new problem.How to do mapping  
of making a object of nested type.

my document structure is -

{  
"\_id": "inspectionresults-07d864fd-76ec-427a-a1c6-b70e420ce3d8",  
"\_rev": "12-64c44ddcfcd477dfa86cdb9d3c659748",  
"sectionResults": [

```
   {
       "SectionName": "More Details",
       "itemResults": [
           
           {
               "InspectionItem": "Launch Month",
               "ItemInfo": ""
               
           }
       ]
   }

```

]  
}

and my query is -  
PUT realtek\_release\_v6\_nestedsearch/\_mapping  
{  
"realtek\_release\_v6\_nestedsearch":{  
"properties": {  
"sectionResults":{  
"type": "object",  
"properties": {  
"itemResults":{  
"type": "nested"  
}  
}  
}  
}  
}  
}

error is - "nested object under path [sectionResults] is not of nested  
type"

please send me query according to my document structure.i only wants  
itemResults object of nested type.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4be1b236-9233-4d41-a66c-a821667ed4ea%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4be1b236-9233-4d41-a66c-a821667ed4ea%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:56am UTC](https://discuss.elastic.co/t/nested-filter-query-giving-error/20234/4 "2017-07-06T00:56:09Z")

</div>


