Wrong matching on nested boolean field


(Andrey Vyrodov) #1

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?


(Andrey Vyrodov) #2

Never mind. Wrong field name :frowning:


(system) #3

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