# Search API returns zero hits

**URL:** <https://discuss.elastic.co/t/search-api-returns-zero-hits/185963>\
**Category:** Elasticsearch\
**Created:** [June 16, 2019, 8:38am UTC](https://discuss.elastic.co/t/search-api-returns-zero-hits/185963 "2019-06-16T08:38:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elk11](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@elk11](https://discuss.elastic.co/u/elk11)\
**Post date:** [June 16, 2019, 8:38am UTC](https://discuss.elastic.co/t/search-api-returns-zero-hits/185963/1 "2019-06-16T08:38:19Z")

</div>

Hi,

I have been witnessing a weird behavior when trying to query elasticsearch.

Ex:

```
GET my_logs*/_search
{
  "query": {"bool": {"must": [
    {"range": {"timestamp": {"gt": "now-1M"}}}
                                               ]
                                      }
  }
}

```

returns:

```
{
  "took" : 8,
  "timed_out" : false,
  "_shards" : {
    "total" : 13,
    "successful" : 13,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  }
}

```

Whereas, If I change 'range' to 'now-2w' , the query returns hits. I'm confused with this behaviour, if 2 weeks old data query returns hits, why does 1 month old returns zero hits.

I don't see any errors in elasticsearch logs. (Discover tab in Kibana shows proper results as expected)

Elasticsearch version: 7.0.0

---

<div class="post-metadata">

**Author:** ![HenningAndersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henningandersen/32/48188_2.png) [@HenningAndersen](https://discuss.elastic.co/u/HenningAndersen)\
**Post date:** [June 16, 2019, 3:07pm UTC](https://discuss.elastic.co/t/search-api-returns-zero-hits/185963/2 "2019-06-16T15:07:13Z")

</div>

Hi @elk11,

I get same problem against master and 7.0. Please open an issue for this on [github](https://github.com/elastic/elasticsearch/issues). It would be good to make a mini-example demonstrating the issue as well as to reference this discussion.

At least with my data, it seems like the issue is only with `gt` and that `gte` works fine. Maybe that can be a usable workaround?

---

<div class="post-metadata">

**Author:** ![elk11](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@elk11](https://discuss.elastic.co/u/elk11)\
**Post date:** [June 17, 2019, 6:44am UTC](https://discuss.elastic.co/t/search-api-returns-zero-hits/185963/3 "2019-06-17T06:44:11Z")

</div>

Thanks, @HenningAndersen.

Your suggested workaround of using 'gte' does work for me. I'll open as issue in elasticsearch github.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [June 17, 2019, 9:47pm UTC](https://discuss.elastic.co/t/search-api-returns-zero-hits/185963/4 "2019-06-17T21:47:57Z")

</div>

Closing the loop, the issue opened was [https://github.com/elastic/elasticsearch/issues/43277](https://github.com/elastic/elasticsearch/issues/43277)

---

<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 15, 2019, 9:48pm UTC](https://discuss.elastic.co/t/search-api-returns-zero-hits/185963/5 "2019-07-15T21:48:19Z")

</div>

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