#community-help

Sorting Results by Weighted Query with Name & Distance

TLDR Vaibhav asked how to sort results by weighted query. Jason provided a solution, while Kishore Nallan clarified that aggregate scores based on weights are not possible.

Powered by Struct AI
5
10mo
Solved
Join the chat
Feb 06, 2023 (10 months ago)
Vaibhav
Photo of md5-0117159aeed7d167f44293e99d32bb26
Vaibhav
05:29 AM
I want to sort my results by a weighted query with both name and distance using latitude and longitude. Any guidance on how to do this?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:32 AM
It would be something like:

sort_by: "name:asc,location(48.853, 2.344):asc"
05:32
Jason
05:32 AM
However, this will only cause geo sorting to kick-in when name is a tie for a particular set of records. The geo sort will help break the tie
Vaibhav
Photo of md5-0117159aeed7d167f44293e99d32bb26
Vaibhav
05:48 AM
Is there a way I could weigh the results 50 50 through Typesense?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
05:59 AM
That's not possible. Weights are used for tie breaking and setting relative important. We don't compute an aggregate score based on weights.