# Confused on bool queries results

**URL:** <https://discuss.elastic.co/t/confused-on-bool-queries-results/184029>\
**Category:** Elasticsearch\
**Created:** [June 3, 2019, 5:15pm UTC](https://discuss.elastic.co/t/confused-on-bool-queries-results/184029 "2019-06-03T17:15:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![b179d8020cf9d624abb2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/b179d8020cf9d624abb2/32/47374_2.png) [@b179d8020cf9d624abb2](https://discuss.elastic.co/u/b179d8020cf9d624abb2)\
**Post date:** [June 3, 2019, 5:15pm UTC](https://discuss.elastic.co/t/confused-on-bool-queries-results/184029/1 "2019-06-03T17:15:23Z")

</div>

The following two queries gives me different results when some documents has missing fields:  
Query1, SELECT \* FROM table WHERE colE \<= 9 OR colD \>= 6

```
{
  "query": {
    "bool": {
      "should": [
        {
          "range": {
            "colE": {
              "lte": "9"
            }
          }
        },
        {
          "range": {
            "colD": {
              "gte": "6"
            }
          }
        }
      ]
    }
  }
}

```

Query2, SELECT \* FROM table WHERE NOT (colE \> 9 AND colD \< 6)

```
{
    "query": {
    "bool": {
      "must_not": [
        {
          "bool": {
            "filter": [
              {
                "range": {
                  "colE": {
                    "gt": "9"
                  }
                }
              },
              {
                "range": {
                  "colD": {
                    "lt": "6"
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

```

The difference is that the 2nd query will return one more document that does not have colD and w/ colE = 14. Can anyone provide some hints on the difference between these 2 queries (especially on how they deal with missing fields)? Thank you so much!

---

<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 1, 2019, 5:15pm UTC](https://discuss.elastic.co/t/confused-on-bool-queries-results/184029/2 "2019-07-01T17:15:24Z")

</div>

Closed on July 1, 2019, 5:15pm UTC

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