# Function score - random score and Scan query?

**URL:** <https://discuss.elastic.co/t/function-score-random-score-and-scan-query/14621>\
**Category:** Elasticsearch\
**Created:** [November 27, 2013, 8:14pm UTC](https://discuss.elastic.co/t/function-score-random-score-and-scan-query/14621 "2013-11-27T20:14:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Conlin](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Mark\_Conlin](https://discuss.elastic.co/u/Mark_Conlin)\
**Post date:** [November 27, 2013, 8:14pm UTC](https://discuss.elastic.co/t/function-score-random-score-and-scan-query/14621/1 "2013-11-27T20:14:04Z")

</div>

I am attempting to read N random docs from an index. To do this I was using  
function\_score query with a match all query and a random\_score.

For a non scan search this works great. I get a different random set of  
docs each time.

For a scan search (lets say N is really big), this doesn't appear to work.  
Subsequent calls using the scroll ids returned are always the same order.

http:  
[//localhost:9200/sampleindex/\_search?search\_type=scan&scroll=60m&size=1000](https://localhost:9200/sampleindex/_search?search_type=scan&scroll=60m&size=1000)

{  
"query": {  
"function\_score": {  
"query": {  
"match\_all": {}  
},  
"random\_score": {}  
}  
}  
}

I have tried setting random seeds, but that did not make the scan query  
return docs in a random order.  
'random\_score': {'seed': 11819}

Any thoughts?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6bf71a02-6be2-409c-97a7-45dc03d6f5d1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6bf71a02-6be2-409c-97a7-45dc03d6f5d1%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:04am UTC](https://discuss.elastic.co/t/function-score-random-score-and-scan-query/14621/2 "2017-07-06T02:04:26Z")

</div>


