Reading the docs I see for the Ranking Parameter: ...
# community-help
j
Reading the docs I see for the Ranking Parameter:
Copy code
query_by_weights
that its default value is:
Copy code
If no explicit weights are provided, fields earlier in the query_by list will be considered to have greater weight.
Is it possible to know what exactly are the values? I am trying to tweak the weights, and it would be great to know what the actual defaults are. For 3 params, would it be 3,2,1?
j
For 3 params the default weights would be 4, 2, 1. For 4 params it would be 8, 4, 2, 1 and so on
j
And for 2 params?
2, 1 ?
j
That's right
🙌 1
j
OK thanks!
👍 1
Trying to use the parameter with our 2 sortBy elements, I broke the search... What's wrong with: queryByWeights: '3,2'
j
What issue are you seeing with those weights?
j
The search does not work at all
It must be a syntax/formatting issue I guess
j
You should see any errors returned in the API response
j
OK, got it.
Copy code
"Number of weights in `query_by_weights` does not match number of `query_by` fields."
In fact my original question was wrong. What I would like to do is change the weighting of the SORTBY fields... Is that possible?
j
Could you elaborate on that what you mean by "weighting" as it relates to sorting? Because when you sort by multiple fields, we use a tie-breaking mechanism. So if you have field1,field2,field3 as sorts, we sort by field 1, and then if two documents have the same value for field1, we use the value for field2 to break the tie and so on.
j
Basically, what I would like to do is boost a bit the results (put them closer to the top) given the second sort element. Knowing that are second sort element is not a queryBy field (since it is the number of sales of that product!).
j
You can essentially force the text match score to tie using
buckets
and then get Typesense to sort using your own field within each bucket
j
OK, understood. Now can you confirm that having one bucket only basically would mean that the text match (first sort element) would become useless?
I am trying to understand how to set the number of buckets... Is 10 a usually good value?
I'd recommend starting with 10, and then tweaking it up or down based on the results you see.
👍 1
j
OK, excellent!