Inconsistent results while querying on a index

I think you are confusing preference and routing.

Say you have an index with 2 primary shards, that have one replica shard each. This is a total of 4 shards. Let's call the primary shards 0P and 1P, and the replica shards 0R and 1R.

Routing by user id would allow you to make sure that all documents from the same user id will be on the same shard. For instance maybe all documents from user foo would be on shards 0P and 0R while all documents from user bar would end up on shards 1P and 1R. So at search time, if you know which user you are searching on, you can configure routing and only go to the shard that holds data for this user.

On the contrary, preference doesn't do anything at index time. But at search time it will make sure that you always hit the same shards if you specify the same preference. Without preference the first search request might go to shards 0P and 1R while the second search request will go to 0R and 1R. With preference configured, you are guaranteed to always hit the same shards.