# Potential bug found: why these queries return different results?

**URL:** <https://discuss.elastic.co/t/potential-bug-found-why-these-queries-return-different-results/29319>\
**Category:** Elasticsearch\
**Created:** [September 15, 2015, 1:20pm UTC](https://discuss.elastic.co/t/potential-bug-found-why-these-queries-return-different-results/29319 "2015-09-15T13:20:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_George](https://avatars.discourse-cdn.com/v4/letter/b/58956e/32.png) [@Ben\_George](https://discuss.elastic.co/u/Ben_George)\
**Post date:** [September 15, 2015, 1:20pm UTC](https://discuss.elastic.co/t/potential-bug-found-why-these-queries-return-different-results/29319/1 "2015-09-15T13:20:34Z")

</div>

_This original topic was regarding version 1.3.4. I tested against 1.7.2 and it appears to work as expected returning same results for both queries (ie: the has\_parent filter actually works). Frustratingly it also works in 0.20.2, the previous version of ES that we used!_

_Having incorrect results return from queries could prove fatal for a search product. This is now the 2nd bug we have found that results in inconsistent or incorrect search results since upgrading from 0.20.2 -\> 1.7.2._

I have two queries that I thought should return identical results, can anyone tell me why they would return different results ?

**There are NO journalist documents with media\_categories\_id 4.**

First query returns 2 results.

```
{
  "query": {
    "constant_score": {
      "filter": {
        "has_parent": {
          "type": "journalist",
          "query": {
            "terms": {
              "media_categories_id": [
                4
              ]
            }
          }
        }
      }
    }
  }
}

```

Second query returns 0 results as expected.

```
{
  "query": {
    "has_parent": {
      "type": "journalist",
      "query": {
        "terms": {
          "media_categories_id": [
            4
          ]
        }
      }
    }
  }
}
```

---

<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 5, 2017, 11:50pm UTC](https://discuss.elastic.co/t/potential-bug-found-why-these-queries-return-different-results/29319/2 "2017-07-05T23:50:03Z")

</div>

Closed on July 5, 2017, 11:50pm UTC


