# Problem in search nested type object

**URL:** <https://discuss.elastic.co/t/problem-in-search-nested-type-object/20282>\
**Category:** Elasticsearch\
**Created:** [October 16, 2014, 10:59am UTC](https://discuss.elastic.co/t/problem-in-search-nested-type-object/20282 "2014-10-16T10:59:13Z")\
**Posts on this page:** 5\
**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 16, 2014, 10:59am UTC](https://discuss.elastic.co/t/problem-in-search-nested-type-object/20282/1 "2014-10-16T10:59:13Z")

</div>

Hi All,  
I am facing a problem in searcing a nested object.My document structure  
is -

{  
"sectionResults": [  
{  
"SectionName": "More Details",  
"itemResults": [

```
           {
               "InspectionItem": "Project Name",
               "ItemInfo": ""
               
           }
       ]
   }

```

]  
}

and I have used this mapping query to make itemResults object(in document)  
of nested type -  
PUT realtek\_release\_v6\_nestedsearch/\_mapping  
{  
"realtek\_release\_v6\_nestedsearch":{  
"properties": {  
"sectionResults":{  
"type": "object",  
"properties": {  
"itemResults":{  
"type": "nested"  
}  
}  
}  
}  
}  
}

then i have checked the mapping .In mapping itemResults of nested type.  
Everything if fine here.  
But problem comes in searching query for nested object.my searching query  
is -

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

this query returns 0 matching results.but result exists in database.I do  
not know whether i am doing mistake in mapping or search query.Please help.

--  
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/59cadcb5-33a1-4da1-a552-95a989a77904%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/59cadcb5-33a1-4da1-a552-95a989a77904%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Elke](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@Elke](https://discuss.elastic.co/u/Elke)\
**Post date:** [October 16, 2014, 3:58pm UTC](https://discuss.elastic.co/t/problem-in-search-nested-type-object/20282/2 "2014-10-16T15:58:15Z")

</div>

Hi.

What kind of analyzer do you use? I think it might be a problem with the  
whitespace (Or do you have the same problem if the value does not contain  
whitespaces?).  
In this case you can use a keyword analyzer (so you will not separate the  
words into single token) or map the fields to not\_analyzed.

Am Donnerstag, 16. Oktober 2014 12:59:13 UTC+2 schrieb shekhar chauhan:

> Hi All,  
> I am facing a problem in searcing a nested object.My document structure  
> is -
> 
> {  
> "sectionResults": [  
> {  
> "SectionName": "More Details",  
> "itemResults": [
> 
> ```
> {
> "InspectionItem": "Project Name",
> "ItemInfo": ""
>                
> }
> ]
> }
> 
> ```
> 
> ]  
> }
> 
> and I have used this mapping query to make itemResults object(in document)  
> of nested type -  
> PUT realtek\_release\_v6\_nestedsearch/\_mapping  
> {  
> "realtek\_release\_v6\_nestedsearch":{  
> "properties": {  
> "sectionResults":{  
> "type": "object",  
> "properties": {  
> "itemResults":{  
> "type": "nested"  
> }  
> }  
> }  
> }  
> }  
> }
> 
> then i have checked the mapping .In mapping itemResults of nested type.  
> Everything if fine here.  
> But problem comes in searching query for nested object.my searching query  
> is -
> 
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "nested": {  
> "path": "sectionResults.itemResults",  
> "filter": {  
> "bool": {  
> "must": [  
> {  
> "term": {  
> "itemResults.InspectionItem": "Project Name"  
> }  
> }  
> ]  
> }  
> }  
> }  
> }  
> }  
> }
> 
> this query returns 0 matching results.but result exists in database.I do  
> not know whether i am doing mistake in mapping or search query.Please help.

--  
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/57701159-6000-493b-a0a6-28c054ac22ee%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/57701159-6000-493b-a0a6-28c054ac22ee%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Kresimir\_Slugan](https://avatars.discourse-cdn.com/v4/letter/k/dec6dc/32.png) [@Kresimir\_Slugan](https://discuss.elastic.co/u/Kresimir_Slugan)\
**Post date:** [October 16, 2014, 4:10pm UTC](https://discuss.elastic.co/t/problem-in-search-nested-type-object/20282/3 "2014-10-16T16:10:52Z")

</div>

Try using full element path in term filter -  
"sectionResults.itemResults.InspectionItem"

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

On Thursday, October 16, 2014 12:59:13 PM UTC+2, shekhar chauhan wrote:

> Hi All,  
> I am facing a problem in searcing a nested object.My document structure  
> is -
> 
> {  
> "sectionResults": [  
> {  
> "SectionName": "More Details",  
> "itemResults": [
> 
> ```
> {
> "InspectionItem": "Project Name",
> "ItemInfo": ""
>                
> }
> ]
> }
> 
> ```
> 
> ]  
> }
> 
> and I have used this mapping query to make itemResults object(in document)  
> of nested type -  
> PUT realtek\_release\_v6\_nestedsearch/\_mapping  
> {  
> "realtek\_release\_v6\_nestedsearch":{  
> "properties": {  
> "sectionResults":{  
> "type": "object",  
> "properties": {  
> "itemResults":{  
> "type": "nested"  
> }  
> }  
> }  
> }  
> }  
> }
> 
> then i have checked the mapping .In mapping itemResults of nested type.  
> Everything if fine here.  
> But problem comes in searching query for nested object.my searching query  
> is -
> 
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "nested": {  
> "path": "sectionResults.itemResults",  
> "filter": {  
> "bool": {  
> "must": [  
> {  
> "term": {  
> "itemResults.InspectionItem": "Project Name"  
> }  
> }  
> ]  
> }  
> }  
> }  
> }  
> }  
> }
> 
> this query returns 0 matching results.but result exists in database.I do  
> not know whether i am doing mistake in mapping or search query.Please help.

--  
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/d538201f-39f4-48a6-ad9b-b0f83b0b68ad%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d538201f-39f4-48a6-ad9b-b0f83b0b68ad%40googlegroups.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 17, 2014, 5:06am UTC](https://discuss.elastic.co/t/problem-in-search-nested-type-object/20282/4 "2014-10-17T05:06:48Z")

</div>

Hi Krešimir Slugan,  
Thanks for your reply.I tried full element path in term filter -  
"sectionResults.itemResults.InspectionItem".But still facing same problem(0  
results found).

--  
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/0aad42fd-8fb9-4fbc-b25d-c97d881f3664%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0aad42fd-8fb9-4fbc-b25d-c97d881f3664%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:55am UTC](https://discuss.elastic.co/t/problem-in-search-nested-type-object/20282/5 "2017-07-06T00:55:35Z")

</div>


