# Nested Query Search not working

**URL:** <https://discuss.elastic.co/t/nested-query-search-not-working/93364>\
**Category:** Elasticsearch\
**Created:** [July 17, 2017, 9:15am UTC](https://discuss.elastic.co/t/nested-query-search-not-working/93364 "2017-07-17T09:15:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sid\_1199](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sid\_1199](https://discuss.elastic.co/u/sid_1199)\
**Post date:** [July 17, 2017, 9:15am UTC](https://discuss.elastic.co/t/nested-query-search-not-working/93364/1 "2017-07-17T09:15:58Z")

</div>

I have a mapping written in DSL as follows:

```
class job:
    properties = {
        'company_name': Text(index='not_analyzed', term_vector='yes'),
        'start_date': Text(index='not_analyzed', term_vector='yes'),
        'end_date': Text(index='not_analyzed', term_vector='yes'
}

Job_exp = Nested(
    doc_class=InnerObjectWrapper,
    properties=job.properties
)

```

So, job\_exp is a nested field with property company\_name, start\_date and end\_date. I am running a nested query search as follows:

```
GET /_search
    {
      "query": {
          "bool": {
             "must": [
                
                {
                   "nested": {
                      "path": "job_exp",
                      "query": {
                         "bool": {
                            "must": [
                               {
                                  "match": {
                                     "job_exp.company_name": "Apple"
                                  }
                               }
                            ]
                         }
                      }
                   }
                }
             ]
          }
       }
    }

```

However, I'm getting this error:

```
"type": "illegal_state_exception",
"reason": "[nested] nested object under path [job_exp] is not of nested type"

```

Can someone please help with this error?

---

<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:** [August 14, 2017, 9:16am UTC](https://discuss.elastic.co/t/nested-query-search-not-working/93364/2 "2017-08-14T09:16:33Z")

</div>

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