# Nested query no longer working in ES 6.0

**URL:** https://discuss.elastic.co/t/nested-query-no-longer-working-in-es-6-0/109413
**Category:** Elasticsearch
**Created:** [November 28, 2017, 2:20pm UTC](https://discuss.elastic.co/t/nested-query-no-longer-working-in-es-6-0/109413 "2017-11-28T14:20:46Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![creaticious](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/creaticious/32/24784_2.png) [@creaticious](https://discuss.elastic.co/u/creaticious)
#### Post date: [November 28, 2017, 2:20pm UTC](https://discuss.elastic.co/t/nested-query-no-longer-working-in-es-6-0/109413/1 "2017-11-28T14:20:46Z")

</div>

Hey guys,

we upgraded our system running ES5.4 to ES6.0. We used some nested querys for months that are no longer working after the upgrade...they fail with

"...[nested] nested object under path [dates] is not of nested type"

But the mentioned field has the nested type...

Here is a simplified mapping and query...the real one is way bigger but this one is also not working...

```
PUT products
{
    "settings" : {
        "index" : {
            "number_of_shards" : 3, 
            "number_of_replicas" : 2 
        }
    },
    "mappings": {
      "basics": {
        "properties": {
          "sku": {
            "type": "text",
            "index": "false"
          },
          "title": {
            "type": "text",
            "index": "true"
          },
          "image": {
            "type": "text",
            "index": "false"
          },
          "productmanager": {
            "type": "text",
            "index": "true"
          },
          "dates": {
            "type": "nested",
            "properties": {
              "date-origin": {
                "type": "date",
                "format": "dd.mm.YYYY"
              },
              "date-destination": {
                "type": "date",
                "format": "dd.mm.YYYY"
              },
              "instock": {
                "type": "byte"
              }              
            }
          }
        }
      }
    }
}

```

And the query...

```
GET _search
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "(sku:*)"
          }
        },
        {
          "nested": {
            "path": "dates",
            "query": {
              "bool": {
                "must": [
                  {
                    "term": {
                      "dates.instock": 0
                    }
                  }
                ]
              }
            },
            "inner_hits": {}
          }
        }
      ]
    }
  }
}

```

So i have no idea whats wrong with it...  
Are there any changes to nested types in ES6..i couldnt find anything in the docs...

Thx!!!

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 28, 2017, 2:42pm UTC](https://discuss.elastic.co/t/nested-query-no-longer-working-in-es-6-0/109413/2 "2017-11-28T14:42:53Z")

</div>

Could you provide a full recreation script as described in

> [@About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21):
>
> The heart of the free and open Elastic Stack Elasticsearch is a distributed, RESTful search and analytics engine capable of addressing a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data for lightning fast search, fine‑tuned relevancy, and powerful analytics that scale with ease. warning PLEASE READ THIS SECTION IF IT'S YOUR FIRST POST Some useful links: [elasticsearch reference guide](http://www.elastic.co/guide/en/elasticsearch/reference/current/index.html)[elasticsearch user guide](http://www.elastic.co/guide/en/elasticsearch/guide/current/index.html)[elasticsearch plugins](https://www.elastic.co/guide/en/elasticsearch/plugins/current/index.html)[elasticsearch cl…](https://www.elastic.co/guide/en/elasticsearch/client/index.html)

It will help to better understand what you are doing.  
Please, try to keep the example as simple as possible.

---

<div class="post-metadata">

### Author: ![creaticious](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/creaticious/32/24784_2.png) [@creaticious](https://discuss.elastic.co/u/creaticious)
#### Post date: [November 28, 2017, 5:02pm UTC](https://discuss.elastic.co/t/nested-query-no-longer-working-in-es-6-0/109413/3 "2017-11-28T17:02:01Z")

</div>

Sorry , i edited my post to meet the standards...

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 28, 2017, 9:06pm UTC](https://discuss.elastic.co/t/nested-query-no-longer-working-in-es-6-0/109413/4 "2017-11-28T21:06:22Z")

</div>

Great. Could you provide as well some sample documents?  
So we can replay your test?

---

<div class="post-metadata">

### Author: ![creaticious](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/creaticious/32/24784_2.png) [@creaticious](https://discuss.elastic.co/u/creaticious)
#### Post date: [November 29, 2017, 7:21am UTC](https://discuss.elastic.co/t/nested-query-no-longer-working-in-es-6-0/109413/5 "2017-11-29T07:21:10Z")

</div>

Of course...here is a simple document...let's say i want to receive all product-dates with instock=1...  
I'm always getting the error as above...

```
PUT products/basics/1
{
    "sku" : "12345",
    "title" : "test product",
    "image" : "test_high.jpg",
    "productmanager": "none",
    "dates":[
      {
        "date-origin": "01.01.2018",
        "date-destination": "10.01.2018",
        "instock": 1
      },
      {
        "date-origin": "20.01.2018",
        "date-destination": "30.01.2018",
        "instock": 0
      }
    ]
}
```

---

<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: [December 27, 2017, 7:21am UTC](https://discuss.elastic.co/t/nested-query-no-longer-working-in-es-6-0/109413/6 "2017-12-27T07:21:50Z")

</div>

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