Different sorted result on same shard on different nodes

I have a cluster with 2 data nodes, each node has one shard. When I make a query, I sort by a date field but I get inconsistent result if I perform the same query twice.

This is because (I think) ES hits the nodes in round-robin, and each node sorts the data slightly differently. Using preference: my_user_id doesn't help because I already hit the only available shard every time, it looks like the data in the shard is not the same across nodes. In fact, if I always hit a single node using preference: "_prefer_nodes:orgKQBy5TyGcduyZ2MEVUw" I get consistently sorted results.

How could I get a consistent sort without forcing my query on a specific node ? Aren't the shards identical across nodes ? Would the use of an additional tie-breaker sort help ?

thanks!

When you say that there is an inconsistent sort order, do you mean for documents with the same date? If two documents have the same date, then the secondary sort order can be different on different shard copies.

If you have some sort of unique value in every document, you could use that as the secondary sort criterion to get to a consistent order.

Thanks for the suggestion @abdon, adding a unique sorting value did the trick!