How can i get random item from algolia?

I am develop a quiz aplication and i use algolia for filter question by specialies.How can i randomize my results.I think when i filter my questions by algolia for 20 items every time i will get same result.Is there any way get random items at server side.

Hi @zgrsln34

Nope, we’re designed for search, so randomization is outside our scope.

But there are some tricks you can with ranking to randomize results – you can influence sort order by injecting a new attribute into your records. This is a pattern we use for injecting external popularity or review scores for sorting. In your case you would just inject a random number on each record and update them at intervals.

Otherwise you’d need to do the randomization on the client side.

One way is to use the Algolia API’s shuffle method, which shuffles the search results randomly. This can be achieved by passing the shuffle option in your search query like this:

index.search(‘your query’, {
hitsPerPage: 20,
shuffle: true
})
Example!
This will randomize the order of the search results each time the query is executed.