Using custom_score to pull random results yields slow query

I am using the following query on a 200 million size index

curl -XPOST "http://xxxx:9200/leads/household/_search" -d'
{"query":
{"custom_score":
{"script":"round(random()*100000)",
"query":{"match_all": {}}}},
"sort":{"_score":{"order":"desc"}},
"fields":["household_id"],
"size":20000}'

To pull 20K records from the index in random, the match_all represent worse
case scenario.

The query takes a very long time, over 7 minutes for 1 shard.

I would like to know if there is a better way to approach this problem of
random results

Thanks

--
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.
For more options, visit https://groups.google.com/groups/opt_out.