# Distinct values of one field based on date range

**URL:** <https://discuss.elastic.co/t/distinct-values-of-one-field-based-on-date-range/257176>\
**Category:** Elasticsearch\
**Created:** [December 1, 2020, 9:17am UTC](https://discuss.elastic.co/t/distinct-values-of-one-field-based-on-date-range/257176 "2020-12-01T09:17:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohlik](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@Rohlik](https://discuss.elastic.co/u/Rohlik)\
**Post date:** [December 1, 2020, 9:17am UTC](https://discuss.elastic.co/t/distinct-values-of-one-field-based-on-date-range/257176/1 "2020-12-01T09:17:25Z")

</div>

Hello community 👋 ,  
I struggling with Elasticsearch query and sadly I cannot get correct response. 😒  
What I want is get unique/disctinct values for specific field in last X minutes.  
I have something like this:

```auto
    GET my-index*/_search
    {
      "size": 0,
      "query": {
        "range": {
          "@timestamp": {
            "gt": "now-15m"
          }
        }
      },
      "aggs": {
        "Data": {
          "terms": {
            "field": "name"
          }
        }
      }
    }

```

I got this response:

```auto
    {
      "took" : 50,
      "timed_out" : false,
      "_shards" : {
        "total" : 128,
        "successful" : 128,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : {
          "value" : 10000,
          "relation" : "gte"
        },
        "max_score" : null,
        "hits" : []
      },
      "aggregations" : {
        "Data" : {
          "doc_count_error_upper_bound" : 0,
          "sum_other_doc_count" : 0,
          "buckets" : []
        }
      }
    }

```

As you can see, there is no related output. What is wrong with my query?  
Thank you.

---

<div class="post-metadata">

**Author:** ![Rohlik](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@Rohlik](https://discuss.elastic.co/u/Rohlik)\
**Post date:** [December 10, 2020, 5:33pm UTC](https://discuss.elastic.co/t/distinct-values-of-one-field-based-on-date-range/257176/2 "2020-12-10T17:33:41Z")

</div>

BUMB!  
Nobody? 🤨

---

<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:** [January 7, 2021, 5:33pm UTC](https://discuss.elastic.co/t/distinct-values-of-one-field-based-on-date-range/257176/3 "2021-01-07T17:33:43Z")

</div>

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