Hi guys, i have a scenarios tried some ways but no...
# community-help
p
Hi guys, i have a scenarios tried some ways but not able to get it right my example collection
Copy code
email 
id 
description
i want to rank the result where users with having email are ranked first with id desc tried doing sort_by email(missing_values:last):desc, _text_match:desc, id:desc but looks like missing_values is last one to sort so it always like email desc any other ways this can be done ? thanks in advance
j
sort_by uses a tie-breaking to sort on multiple fields. So in your case it will first sort on email (and place missing values last), and then if two records tie by having the same email address, then _text_match is used to break the tie. And then if that also ties, then id is used to break the tie. You could use the new filter-based sorting mechanism we’ve added in 0.24.0.rcn25 to implement your use case. Something like:
"sort_by": "_eval(has_email:true):asc,id:desc"
where
has_email
is a new boolean field you’ll have to create at indexing time to each record
p
will try this. thank you 🙂