# Force range query to use epoch\_second instead of epoch\_millies?

**URL:** <https://discuss.elastic.co/t/force-range-query-to-use-epoch-second-instead-of-epoch-millies/156581>\
**Category:** Elasticsearch\
**Created:** [November 14, 2018, 5:26am UTC](https://discuss.elastic.co/t/force-range-query-to-use-epoch-second-instead-of-epoch-millies/156581 "2018-11-14T05:26:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sjaak01](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@Sjaak01](https://discuss.elastic.co/u/Sjaak01)\
**Post date:** [November 14, 2018, 5:26am UTC](https://discuss.elastic.co/t/force-range-query-to-use-epoch-second-instead-of-epoch-millies/156581/1 "2018-11-14T05:26:05Z")

</div>

Hi,

I noticed epoch\_second can be as much as 200x faster than epoch\_millies in Kibana. As millies are not important to me I want all visualizations to use epoch\_second instead of epoch\_millies but I can't find any way to get this done.

I already create a new index and used this as the mapping for my @datetime field. The original value of that field is yyyy-MM-ddTHH:mm:ss.

```
"properties": {
  "@datetime": {
    "type": "date",
    "format": "yyyy-MM-dd'T'HH:mm:ss||epoch_second"
  },

```

However when I create my index Elastic/Kibana seemd to add .000 and the query still shows epoch\_millies when looking at the visualization request.

```
  "range": {
    "@datetime": {
      "gte": 1534396763826,
      "lte": 1542172763826,
      "format": "epoch_millis"
    }

```

How can I force Elastic to use epoch\_seconds? If possible, is there any way to apply this to all existing indeces as well? As I can change the query in the profiler it appears this is done at the query level and doesn't really depend on whatever the actual data in the index might look like?

---

<div class="post-metadata">

**Author:** ![Sjaak01](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@Sjaak01](https://discuss.elastic.co/u/Sjaak01)\
**Post date:** [November 14, 2018, 6:09am UTC](https://discuss.elastic.co/t/force-range-query-to-use-epoch-second-instead-of-epoch-millies/156581/2 "2018-11-14T06:09:22Z")

</div>

Added some ruby code to my logstash to convert @timestamp to epoc in seconds.

Template

> "@epoc": {  
> "type": "date",  
> "format": "epoch\_second"  
> }

and STILL the range query in Kibana is showing as` epoch_millis`. Elastic is just ignoring whatever I set.

---

<div class="post-metadata">

**Author:** ![Sjaak01](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@Sjaak01](https://discuss.elastic.co/u/Sjaak01)\
**Post date:** [November 14, 2018, 8:20am UTC](https://discuss.elastic.co/t/force-range-query-to-use-epoch-second-instead-of-epoch-millies/156581/3 "2018-11-14T08:20:48Z")

</div>

Right, so it appears changing the query to epoch\_seconds actually made it fail, hence the very quick query times.

But reading this I still think going with seconds might be faster as I have a lot of very small documents.

> **[Free unlimited email tracking, scheduling, polls, and surveys for Gmail | Mixmax](https://mixmax.com/blog/30x-faster-elasticsearch-queries/)**
>
> Send engaging emails with instant scheduling, email tracking, polls, and surveys right in your Gmail.

But for the life of me I can't get Elastic to not convert everything to epoch\_millis...

---

<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:** [December 12, 2018, 8:20am UTC](https://discuss.elastic.co/t/force-range-query-to-use-epoch-second-instead-of-epoch-millies/156581/4 "2018-12-12T08:20:54Z")

</div>

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