# Order by a non timestamp parameter

**URL:** <https://discuss.elastic.co/t/order-by-a-non-timestamp-parameter/179926>\
**Category:** Elasticsearch\
**Created:** [May 7, 2019, 9:11am UTC](https://discuss.elastic.co/t/order-by-a-non-timestamp-parameter/179926 "2019-05-07T09:11:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtanzi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mtanzi/32/45499_2.png) [@mtanzi](https://discuss.elastic.co/u/mtanzi)\
**Post date:** [May 7, 2019, 9:11am UTC](https://discuss.elastic.co/t/order-by-a-non-timestamp-parameter/179926/1 "2019-05-07T09:11:19Z")

</div>

Hi,

I am replacing our current search service based on MySQL query with a new service using Elasticsearch. I am running an integration test to make sure that all the existing query match with the new query using Elasticsearch and I noticed that when I order the result by a non timestamp field the result between mysql and ES mismatch.

Let say the order field used is `price`, I see that MySQL returns the results ordered by price and, if there are some results having the same price, it order the result using the `created_at` field as time breaker.

Elasticsearch has a different behavior to return the ordered field by price. Given that the `_score` parameter is null (I am not using any sort of scoring) at the moment, what is the parameter used by ES to perform the final order if the query returns multiple results with the same price.

Thanks in Advance,  
Marco

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 7, 2019, 9:54am UTC](https://discuss.elastic.co/t/order-by-a-non-timestamp-parameter/179926/2 "2019-05-07T09:54:01Z")

</div>

you can sort by more than one parameter, and use the `created_at` field as a tie breaker in Elasticsearch as well - you have to specify it though.

--Alex

---

<div class="post-metadata">

**Author:** ![mtanzi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mtanzi/32/45499_2.png) [@mtanzi](https://discuss.elastic.co/u/mtanzi)\
**Post date:** [May 7, 2019, 10:06am UTC](https://discuss.elastic.co/t/order-by-a-non-timestamp-parameter/179926/3 "2019-05-07T10:06:11Z")

</div>

Thank you Alex for the fast reply!

What is the basic tie breaker used by Elasticsearch ?

...Because maybe it make more sense to my service to keep the ES tie breaker rather then use Mysql behavior...

Marco

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 7, 2019, 10:42am UTC](https://discuss.elastic.co/t/order-by-a-non-timestamp-parameter/179926/4 "2019-05-07T10:42:08Z")

</div>

if you don't specify one, there is none, so IIRC it is currently the order of indexing (but that is non guaranteed and not user friendly)

---

<div class="post-metadata">

**Author:** ![mtanzi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mtanzi/32/45499_2.png) [@mtanzi](https://discuss.elastic.co/u/mtanzi)\
**Post date:** [May 7, 2019, 10:49am UTC](https://discuss.elastic.co/t/order-by-a-non-timestamp-parameter/179926/5 "2019-05-07T10:49:32Z")

</div>

Ok, In that case I will explicitly add the the tie-breaker to the service.

Thanks again!

Marco

---

<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:** [June 4, 2019, 10:49am UTC](https://discuss.elastic.co/t/order-by-a-non-timestamp-parameter/179926/6 "2019-06-04T10:49:38Z")

</div>

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