# Random\_score query brought down ES 5.5 cluster

**URL:** <https://discuss.elastic.co/t/random-score-query-brought-down-es-5-5-cluster/178004>\
**Category:** Elasticsearch\
**Created:** [April 23, 2019, 10:34am UTC](https://discuss.elastic.co/t/random-score-query-brought-down-es-5-5-cluster/178004 "2019-04-23T10:34:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vglazkov](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@vglazkov](https://discuss.elastic.co/u/vglazkov)\
**Post date:** [April 23, 2019, 10:34am UTC](https://discuss.elastic.co/t/random-score-query-brought-down-es-5-5-cluster/178004/1 "2019-04-23T10:34:04Z")

</div>

This question is similar to this one:

> [@This query brought down my cluster :{"query": {"function\_score": {"query": {"match\_all":{}}, "random\_score": {"seed": 123456}}}}](https://discuss.elastic.co/t/this-query-brought-down-my-cluster-query-function-score-query-match-all-random-score-seed-123456/21360):
>
> Hi, I like to share my experience and in the same time hope I can get some tips. The query was run against an index with about 700 million documents. Two things happens, The node run this query crashed. It is the node configured not to proccess data. The data nodes start crazy on GC. eventually old generation gc cannot reduce the heep usage and the nodes becomes unresponsive. in some cases. OLD generation gc even increased size of the heap: 2014-12-20 07:21:03,370][WARN][mon…

The difference between the tickets is that I have intentionally specified `size` parameter. Index contains little more than 8 billions of documents. Here's my query:

```auto
{
    "version": true,
	"size": 5000,
	"query": {
		"function_score": {
			"query": {
				"bool": {
					"must": {
						"match_all": {}
					},
					"filter": {
						"range": {
							"updated": {
								"lte": "1556015239000"
							}
						}
					}
				}
			},
			"functions": [{
				"random_score": {
					"seed": 0
				}
			}]
		}
	}
}

```

My question is why did this happen?

---

<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:** [April 23, 2019, 4:16pm UTC](https://discuss.elastic.co/t/random-score-query-brought-down-es-5-5-cluster/178004/2 "2019-04-23T16:16:31Z")

</div>

`size: 5000` only returns 5000 documents in the search response (which also is a lot and you should consider using scroll searches). However in order to get those 5000 documents the script score query needs to be executed against every hit that matches the query in the function score, which may be far more than those 5k.

---

<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:** [May 21, 2019, 4:16pm UTC](https://discuss.elastic.co/t/random-score-query-brought-down-es-5-5-cluster/178004/3 "2019-05-21T16:16:40Z")

</div>

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