Get every Nth result in Elasticsearch -
i have large set of data , want sample can use in graph. don't need of data, need every nth item.
for instance if have 4000 results, , need 800 results, want able every 5th result.
so like: get, skip, skip, skip, skip, get, skip, skip, skip,..
i wondering if such thing possible in elasticsearch?
you're better off using scripted filter
. otherwise you're needlessly using score. filters queries, don't use scoring.
post /test_index/_search { "query": { "filtered": { "filter": { "script": { "script": "doc['unique_counter'].value % n == 0", "params" : { "n" : 5 } } } } } }
you're better off not using dynamic scripting in real world usage.
that said, want take @ aggregations graphing analytical information data rather taking arbitrary sample.
Comments
Post a Comment