Typesense Query and Matching Explained.
TLDR David queried about Typesense's query weights and matching. Jason clarified that Typesense prioritizes exact matches in the same field, which can be changed with 'prioritize_exact_matches: false'.
1
Oct 28, 2022 (14 months ago)
David
12:58 PM{
id: 1
productName: "Stripe",
variantName: "Throw, Black / White"
},
{
id: 2
productName: "Monster",
variantName: "Throw, Ochre / Off-white Stripe"
}
I've set my params to prioritise
productName
over variantName
, like this query_by: 'sku,productName,variantName,designer,tags', query_by_weights: '5,4,3,1,2'
. When I search stripe throw
, id 2 comes before id 1, even through id 1 is an exact hit of the more prioritised field. Why? id 2 has two exact matches in its variantName
, but I still don't want that to "win" as the productName
match is more important for me.Images in 🧵
David
01:03 PMJason
03:18 PMDavid
03:29 PMJason
04:13 PMDavid
05:17 PM1
Typesense
Indexed 3015 threads (79% resolved)
Similar Threads
Enhancing Search Term Matching with Query Weight Parameter
John questions if there's a solution to control term matching in search fields despite `query_weight`. Jason suggests an approach whereas Kishore Nallan cites earlier dissatisfaction with similar method but is open to think over alternatives. John further suggests a potential solution but resolution is still pending.
Sorting Search Results Based on Weights
Pantelis wanted to sort search results by weight. Kishore Nallan suggested using "prioritize_exact_match: false" and "text_match_type: 'max_weight'" to achieve the desired result.
Relevancy Ordering Issue in Typesense
Ellen was having an issue with the relevancy ordering in Typesense. Jason suggested setting `prioritize_exact_match` to false and testing on version `0.24.0.rcn22`.