PeteP
Convex Community3mo ago
2 replies
Pete

How to optimize strings for search relevance?

I have a query that takes a search term and searches through records using .withSearchIndex The records have multiple fields like
name
, description, artist, song, album which I concatenate into a single string and store as a searchDescription field.

I can't tell from the docs how I can optimize this field. While the results generally return in a sensible order, there are some results that I don't quite understand.

For example, given the search term "metallica," why does "AJFA Tone AJFA TONE metallicabossmk2" return higher in the order than ""metallica metallica Felipeisloco399" ?

I would expect the second result to be ranked higher since the search term appears twice and appears at the beginning of the string.
Was this page helpful?