# Random sampling in elasticsearch to elasticsearch copy

**URL:** <https://discuss.elastic.co/t/random-sampling-in-elasticsearch-to-elasticsearch-copy/94540>\
**Category:** Elasticsearch\
**Created:** [July 25, 2017, 9:10pm UTC](https://discuss.elastic.co/t/random-sampling-in-elasticsearch-to-elasticsearch-copy/94540 "2017-07-25T21:10:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 25, 2017, 9:10pm UTC](https://discuss.elastic.co/t/random-sampling-in-elasticsearch-to-elasticsearch-copy/94540/1 "2017-07-25T21:10:23Z")

</div>

I want to take a copy of some production Elasticsearch indexes and put a sample of them into a test cluster. I can use logstash to do the copy, and I know I can filter it in logstash using something like

> filter { ruby { code =\> "event.cancel if rand \<= 0.99" } }

However, I would like to be able to do the filtering in Elasticsearch so that logstash never sees the records it is going to drop. If they were small indexes I could use random\_score and size to filter top-N, but my understanding is that that will not scale to asking for the top 10,000,000 documents. Is there another way?

---

<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:** [August 22, 2017, 9:11pm UTC](https://discuss.elastic.co/t/random-sampling-in-elasticsearch-to-elasticsearch-copy/94540/2 "2017-08-22T21:11:06Z")

</div>

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