# Wrong matching on nested boolean field

**URL:** <https://discuss.elastic.co/t/wrong-matching-on-nested-boolean-field/86281>\
**Category:** Elasticsearch\
**Created:** [May 18, 2017, 2:38pm UTC](https://discuss.elastic.co/t/wrong-matching-on-nested-boolean-field/86281 "2017-05-18T14:38:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrey\_V](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrey_v/32/18337_2.png) [@Andrey\_V](https://discuss.elastic.co/u/Andrey_V)\
**Post date:** [May 18, 2017, 2:38pm UTC](https://discuss.elastic.co/t/wrong-matching-on-nested-boolean-field/86281/1 "2017-05-18T14:38:49Z")

</div>

Hello. I have a strange problem with matching nested boolean field. Testing on ElasticSearch 5.2

Here is an example of document i have:

```
{
  "id": 1234,
  "categories": [
    {
      "l0": 111,
      "l1": 222,
      "l2": 333
    }
  ],
  "models": [
    {
      "id": 234,
      "products": [
        {
          "id": 345,
          "has_free_delivery": false,
         }
      ]
    }
  ]
}

```

And query:

```
GET articles/main/_search?size=60
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "id": 1234
          }
        },
        {
          "nested": {
            "path": "models.products",
            "query": {
              "term": {
                "models.products.has_relay_delivery": true
              }
            },
            "inner_hits": {}
          }
        }
      ]
    }
  }
}

```

As I understand this document should be ignored. But ES returns it

```
{
"_index": "articles",
"_type": "main",
"_id": "1234",
"_score": 10.402443,
"_source": {
  "id": 1234,
  "categories": [
    {
      "l0": 111,
      "l1": 222,
      "l2": 333
    }
  ],
  "models": [
    {
      "id": 234,
      "products": [
        {
          "id": 345,
          "has_free_delivery": false
        }
      ]
    }
  ]
},
"inner_hits": {
  "models.products": {
    "hits": {
      "total": 1,
      "max_score": 1.5755799,
      "hits": [
        {
          "_nested": {
            "field": "models",
            "offset": 0,
            "_nested": {
              "field": "products",
              "offset": 0
            }
          },
          "_score": 1.5755799,
          "_source": {
            "id": 345,
            "has_free_delivery": false                    
          }
        }
      ]
    }
  }
}

```

Obviously I'm doing somethings wrong but i don't get what. Can someone give a hint or point at problem?

---

<div class="post-metadata">

**Author:** ![Andrey\_V](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrey_v/32/18337_2.png) [@Andrey\_V](https://discuss.elastic.co/u/Andrey_V)\
**Post date:** [May 18, 2017, 2:49pm UTC](https://discuss.elastic.co/t/wrong-matching-on-nested-boolean-field/86281/2 "2017-05-18T14:49:30Z")

</div>

Never mind. Wrong field name ☹

---

<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:** [June 15, 2017, 2:50pm UTC](https://discuss.elastic.co/t/wrong-matching-on-nested-boolean-field/86281/3 "2017-06-15T14:50:01Z")

</div>

Closed on June 15, 2017, 2:50pm UTC

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