#community-help

Optimizing Search Results with Typesense

TLDR em1nos asked for a way to get exact match results first in Typesense. Jason answered, recommending the use of a scoring system that factors in string length.

Powered by Struct AI

1

3
15mo
Solved
Join the chat
Sep 16, 2022 (15 months ago)
em1nos
Photo of md5-f33ae8b829901656b655c985c894be3a
em1nos
07:10 PM
I'm sure I'm missing something simple here, but. Is there a way to prefer "more exact/shorter" search results. For example: Query: "iphone 14". Results: iPhone 14 128GB should be before iPhone 14 Pro 128GB, and iPhone 14 Pro Max 128GB... etc.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:35 PM
Typesense doesn’t take string length of unmatched words into account for ranking… It only ranks exact matches on top.

I’d recommend using a score of some sort that does take string length into account in the formula, add that to each record and then sort by that to account for this
em1nos
Photo of md5-f33ae8b829901656b655c985c894be3a
em1nos
07:36 PM
OK. Thank you!

1