# Random sampling performance

**URL:** <https://discuss.elastic.co/t/random-sampling-performance/20712>\
**Category:** Elasticsearch\
**Created:** [November 12, 2014, 6:05pm UTC](https://discuss.elastic.co/t/random-sampling-performance/20712 "2014-11-12T18:05:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wisllay\_vitrio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wisllay_vitrio/32/1117_2.png) [@wisllay\_vitrio](https://discuss.elastic.co/u/wisllay_vitrio)\
**Post date:** [November 12, 2014, 6:05pm UTC](https://discuss.elastic.co/t/random-sampling-performance/20712/1 "2014-11-12T18:05:09Z")

</div>

I have an ElasticSearch index with 20+ million documents, which I'm using  
to perform GeoBoundingBox filters, combined to other queries.  
I'd like to have, for each search, a random sample from my results.  
After reading the documentation, I tried using the RandomScoreFunction,  
which gives a random score to each result from my queries.  
The problem is performance wise. Applying this over around 10 million  
documents (which can happen sometimes), takes more than  
10 seconds. Actually there the ES cluster have 6 servers, and 10 seconds is  
quite a long time for the kind of application I want.  
Is there anyway to get a consistent sample from my results, preferably  
having a good geographical distribution?

--  
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/2905a438-6dbc-4c01-b4d1-ff00feefc3bf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2905a438-6dbc-4c01-b4d1-ff00feefc3bf%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:50am UTC](https://discuss.elastic.co/t/random-sampling-performance/20712/2 "2017-07-06T00:50:26Z")

</div>


