# Inconsistent result order (same score)

**URL:** <https://discuss.elastic.co/t/inconsistent-result-order-same-score/107817>\
**Category:** Elasticsearch\
**Created:** [November 15, 2017, 7:44pm UTC](https://discuss.elastic.co/t/inconsistent-result-order-same-score/107817 "2017-11-15T19:44:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ParitoshBh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paritoshbh/32/22487_2.png) [@ParitoshBh](https://discuss.elastic.co/u/ParitoshBh)\
**Post date:** [November 15, 2017, 7:44pm UTC](https://discuss.elastic.co/t/inconsistent-result-order-same-score/107817/1 "2017-11-15T19:44:27Z")

</div>

Here's what I am trying to accomplish,

Documents are categorized into category names and I am trying to fetch all documents under a certain category. This works out as expected using the following snippet,

```auto
'index' => 'test_index',
'type' => 'test_type',
'body' => [
	'from' => 0,
	'size' => 20,
	'query' => [
		'bool' => [
			'must' => [
				'match_phrase' => [
					'cat_name' => 'elastic'
				]				
			]
		]
	]
]

```

The problem is the result order changes each time the query is run and seeing that the scores returned are all the same (at-least on the first page), I believe this is the reason.

To get around this, I came across `preference` parameter which tries to keep things consistent but this would not work if the same query was run by a different user (think a website user).

Another alternative is to wrap this in a `dis max` query with `tie_breaker` but I believe this isn't what I am looking for considering there would be just one bool query in it.

I have been looking around the documentation and it feels like I am overthinking this a bit too much.

Any help will be appreciated 🙂

---

<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 13, 2017, 7:44pm UTC](https://discuss.elastic.co/t/inconsistent-result-order-same-score/107817/2 "2017-12-13T19:44:35Z")

</div>

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