Pete
Pete2w ago

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.
2 Replies
Convex Bot
Convex Bot2w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Pete
PeteOP2w ago
(I understand that something like elaticsearch or algolia would be ideal for this but I'm trying to keep my implementation as simple as possible and avoid extraneous services for now)

Did you find this page helpful?