Please help. How to sort if more than three fields...
# community-help
p
Please help. How to sort if more than three fields. I have
Copy code
sort_by='is_featured:desc,isOnline:desc,_text_match:desc,updated_at:desc';
And i am getting error as max three fields allowed. I want featured with online users as priority. featured and isOnline are bool.
j
You want to combine any additional sorting criteria into a single numeric field using any formula of your choice and use that field for sorting
p
Hi @Jason Bosco...thanks but i could not get your question correctly. do you mean if I am aware of typesense allowing me to use any formula for sorting by combining one or two fields? I just want these fields in priorty first
Copy code
is_featured:desc,isOnline:desc,_text_match:desc,updated_at:desc
So you can say Featured users will be given priority and within featured online users and within this who is latest and within who match text. Similarly for among unfeatured.
I saw _eval() can be used as a way to combine but still not able to meet my expectation because it finally evaluates to true or flase.
j
I think I see what you mean now. You can sort based on different conditions, and assign scores to each condition using Filter Scoring: https://typesense.org/docs/27.1/api/search.html#sorting-based-on-filter-score