Randomise hits results every iterations

Is there any way to randomise the search hits every I rerun a query?

Due to the large number of hits, I just want to sample my results and do some statistical test on it. However, I have yet to find a way to randomise the search hits.

I read about function_score, however it seem to return the same of set of hits every time I rerun the query. I tried with different seed_number also, but there's no change after every rerun.

Here my code

    "size": 1000, 
    "sort": [{"gc_transaction": "desc"}],
    "query": {
        "function_score": {
            "query": {
                "bool": {
                    "filter": {
                        "range": {
                            "@timestamp": {
                                "gte": "now-30d", 
                                "lte": "now", 
                                "format": "strict_date_optional_time"
                            }
                        }
                    }, 
                    "must": [
                    ], 
                },
            },
            "random_score": {"seed": 3241325325}, 
            "score_mode": "sum"
        } 
    }

Have you tried omitting the seed parameter as in this first example?

Yes, I tried that firstly and because it didn't work, I tried with the seed paramater.

What if you remove the seed and the sort settings?

Then how would I paginate through the results? I want to get at least 10k results (my company lib for elasticsearch only allow 1k results each query). Is there other way to paginate without sorting?

Might have been usseful to mention this up front. Have you tried using a static seed parameter for all related requests without sorting while paging?

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