# Sorting events with identical millis timestamps by order events were recorded

**URL:** https://discuss.elastic.co/t/sorting-events-with-identical-millis-timestamps-by-order-events-were-recorded/297758
**Category:** Kibana
**Created:** [February 21, 2022, 1:07pm UTC](https://discuss.elastic.co/t/sorting-events-with-identical-millis-timestamps-by-order-events-were-recorded/297758 "2022-02-21T13:07:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bublik-hpt](https://avatars.discourse-cdn.com/v4/letter/b/b782af/32.png) [@bublik-hpt](https://discuss.elastic.co/u/bublik-hpt)
#### Post date: [February 21, 2022, 1:07pm UTC](https://discuss.elastic.co/t/sorting-events-with-identical-millis-timestamps-by-order-events-were-recorded/297758/1 "2022-02-21T13:07:52Z")

</div>

Hi i have logs where multiple lines have the same timestamp. In Kibana discover they are in opposite order (if i follow the timestamp) then in the logfile, but when I check surrounding documents they are in correct order. Is it possible to see documents in discovery in correct (time based) order?

example:  
logfile:

```auto
2022-02-21T13:52:15.840 [bookie-io-1-7] INFO org.apache.bookkeeper.proto.AuthHandler - Authentication success on server side
2022-02-21T13:52:15.840 [bookie-io-1-7] INFO org.apache.bookkeeper.proto.BookieRequestHandler - Channel connected [id: 0x3b9d22a3, L:/10.15.24.43:3181 - R:/192.168.255.94:38216]
2022-02-21T13:52:15.840 [bookie-io-1-7] INFO org.apache.bookkeeper.proto.BookieRequestHandler - Channels disconnected: [id: 0x3b9d22a3, L:/10.15.24.43:3181 ! R:/192.168.255.94:38216]

```

discover:

 ![obrazek](https://us1.discourse-cdn.com/elastic/original/3X/c/2/c2dc3ed753d9237f8d58394879e522d640f4d4be.png)

surrounding docs:

 ![obrazek](https://us1.discourse-cdn.com/elastic/original/3X/8/9/89d339d180e066bf59e3af2874ea8506e3c5cbce.png)

Thank you very much.

---

<div class="post-metadata">

### Author: ![matw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matw/32/13913_2.png) [@matw](https://discuss.elastic.co/u/matw)
#### Post date: [February 24, 2022, 9:19am UTC](https://discuss.elastic.co/t/sorting-events-with-identical-millis-timestamps-by-order-events-were-recorded/297758/2 "2022-02-24T09:19:00Z")

</div>

Hi and welcome to our community

So surrounding docs are sorting by `timefield` and `_doc`, Discover itself doesn't.

We might implement this in the future:

> <https://github.com/elastic/kibana/issues/47934>
>
> If you have huge amounts of data with many lots of documents sharing the same ti…mestamp up to the millisecond you might wanna use \`\_doc\` for faster sorting. We should consider adding an option for the user to sort by \`\_doc\` 
> 
> Knowhow about \`\_doc\`:
> 
> \> \_doc has no real use-case besides being the most efficient sort order. So if you don’t care about the order in which documents are returned, then you should sort by \_doc. This especially helps when scrolling.
> 
> We should also provide the option to use a tiebreaker in Discover (by default \`\_doc\`), here's an older PR for that #32426

The only way to currently solve this is if you have an own sequence field you can sort by additionally. Or we also support sorting by a timestamp with nanoseconds

> **[Date nanoseconds field type | Elasticsearch Guide \[8.0\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/date_nanos.html)**

But of course most loggers don't support this

Best,  
Matthias

---

<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: [March 24, 2022, 9:19am UTC](https://discuss.elastic.co/t/sorting-events-with-identical-millis-timestamps-by-order-events-were-recorded/297758/3 "2022-03-24T09:19:40Z")

</div>

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