I there i know typesense is an search engine, but ...
# community-help
f
I there i know typesense is an search engine, but my client is also using it as filter for frontend items, but the result are always the same, does typesense have random sort?
k
👋 Can you please elaborate what you mean by "result are always the same"? I don't follow you.
f
Hi @Kishore Nallan, is using the api call to get results from typesense, but the order of the itens is always the same, i would like to find out if we can add random sort.
k
So a wildcard query is made with just filters?
f
yep
1. filters: “NOT image = ‘noimage’ AND relevance = 1 AND elected = ‘Ar Livre’” 2. limit: 10
k
Okay, in that case, the documents are sorted by their internal IDs (which are ascending and auto incrementing in nature). There is no way to sort randomly, because I have never seen a use case where a random order helps 🙂
👍 1
f
im using right now with another seach engine, but moving to typesense after the tests are concluded..
thats what o thought.
They found out the calling typesense is faster then quering the DB 😄
😅 1
k
One way to "generate" randomness if you really want it. But it's one giant hack: 1. Add a geo field with a random value. 2. During sort_by pass a random geo point as reference value. This would sort results on "distance" from the reference point, but since the geo point is random, the computed distance will always change!
😂 1
f
Humm nice hack 😄
b
If pagination isn't involved, you can always sort the results randomly client-side
f
That could be a trick..