# How to search in nested query for below case

**URL:** <https://discuss.elastic.co/t/how-to-search-in-nested-query-for-below-case/186608>\
**Category:** Elasticsearch\
**Created:** [June 20, 2019, 7:02am UTC](https://discuss.elastic.co/t/how-to-search-in-nested-query-for-below-case/186608 "2019-06-20T07:02:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![princesahu04](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/princesahu04/32/47235_2.png) [@princesahu04](https://discuss.elastic.co/u/princesahu04)\
**Post date:** [June 20, 2019, 7:02am UTC](https://discuss.elastic.co/t/how-to-search-in-nested-query-for-below-case/186608/1 "2019-06-20T07:02:39Z")

</div>

My mapping is:

> ```
> PUT bond_covenant
> {
> "settings": {
> "index":{
> "analysis":{
> "filter":{
> "synonym":{
> "type":"synonym",
> "synonyms":"Some path"
> },
> "english_stop":{
> "type":"stop",
> "stopwords":"_english_"
> },
> "my_stemmer":{
> "type":"stemmer",
> "name":"english"
> }
> },
> "analyzer":{
> "my_custom_analyzer":{
> "type":"custom",
> "tokenizer":"standard",
> "filter":[
> "lowercase",
> "english_stop",
> "synonym",
> "my_stemmer"
> ]
> }
> }
> }
> }
> }, 
> "mappings": {
> "properties": {
> "name":{"type":"text"},
> "doc": {"type":"nested",
> "properties": {
> "file_name":{"type":"text"},
> "published_date":{"type":"text"},
> "container": {"type":"nested",
> "properties": {
> "heading":{"type":"text"},
> "sections":{"type":"nested",
> "properties":{
> "sec_heading":{"type":"text"},
> "sentences": {"type":"nested",
> "properties":{
> "text":{"type":"text",
> "analyzer":"my_custom_analyzer"
> },
> "start_offset":{"type":"integer"},
> "end_offset":{"type":"integer"},
> "key_phrases":{"type":"nested",
> "properties":{
> "score":{"type":"integer"},
> "phrases":{"type":"text"}
> }
> },
> "entities":{"type":"nested",
> "properties":{
> "text":{"type":"text"},
> "type":{"type":"text"},
> "start_offset":{"type":"integer"},
> "end_offset":{"type":"integer"}
> }
> },
> "noun_phrases":{"type":"nested",
> "properties":{
> "text":{"type":"text"},
> "start_offset":{"type":"integer"},
> "end_offset":{"type":"integer"} 
> }
> },
> "sub_sections": {"type":"nested",
> "properties":{
> "text":{"type":"text"
> },
> "start_offset":{"type":"integer"},
> "end_offset":{"type":"integer"},
> "key_phrases":{"type":"nested",
> "properties":{
> "score":{"type":"integer"},
> "phrases":{"type":"text"}
> }
> },
> "entities":{"type":"nested",
> "properties":{
> "text":{"type":"text"},
> "type":{"type":"text"},
> "start_offset":{"type":"integer"},
> "end_offset":{"type":"integer"}
> }
> },
> "noun_phrases":{"type":"nested",
> "properties":{
> "text":{"type":"text"},
> "start_offset":{"type":"integer"},
> "end_offset":{"type":"integer"} 
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> 
> ```

My search query: It's not working

> ```
> GET bond_covenant/_search
> {
> "_source": ["name","doc.container.heading"],
> "query": {
> "nested": {
> "path": "doc",
> "query": {
> "nested": {
> "path": "doc.container",
> "query": {
> "nested": {
> "path": "doc.container.sections",
> "query": {
> "nested": {
> "path": "doc.container.sections.sentences",
> "query": {
> "nested": {
> "path": "doc.container.sections.sentences.sub_sections",
> "query": {
> "match": {
> "doc.container.sections.sentences.sub_sections.text": "hedging"
> }
> }
>   
> }
> }
> }
> }
> }
> }
> }
> }      
> }       
> },
> "highlight": {
> "number_of_fragments":5 , 
> "fragment_size" : 400,
> "no_match_size": 0, 
>       
> "fields" : {
> "doc.container.sections.sentences.sub_sections.text" : {}
> }
> }
> }
> 
> ```

---

<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 18, 2019, 7:02am UTC](https://discuss.elastic.co/t/how-to-search-in-nested-query-for-below-case/186608/2 "2019-07-18T07:02:40Z")

</div>

Closed on July 18, 2019, 7:02am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
