Hey all, I'm setting up TypeSense for ecommerce pr...
# community-help
t
Hey all, I'm setting up TypeSense for ecommerce product search. I have it up on a dev copy of the live database. I am running some tests on a copy of our live data, which includes historic sales. Some of the results are great, and the speed is great. I have a few issues though on trying to work out the best way to slightly promote popular products though (without pinning). I have tried to read up on the official website some techniques but I am struggling to get the results I need. For some Very generic searches which bring back a lot of products (say about 5-10k), The search scores of the tops results are Very similar for a large range of products, but hundreds if not thousands of the 1st ones have no sales at all and so are likely not the best fit. What I would like is to be able to influence the results without doing anything drastic like forcing sold products to the top. Is there a way to make sales stats increase ranking without taking over it? My concerns are: • Result size varies a lot from thousands to 10s, so fixed rules on X size buckets seems unlikely to fit all • Just because a product has sold doesnt mean it should be at the top, so I dont want to blanket push all to the top. Ideally I would be able to say something like 10% of score is based on sold and 90% is based on relevance for example I have tried buckets but they dont seem to give desired results in my tests and doesnt scale well with variable and unknown result sizes. I tried looking here: https://typesense.org/docs/guide/ranking-and-relevance.html#ranking-based-on-relevance-and-popularity Thanks for any advice
k
Typesense doesn't natively support a direct percentage-weighted blend (like "90% relevance + 10% popularity") Options: 1. Use
bucket_size
Instead of
buckets
- This scales better with variable result sizes, e.g. with
bucket_size: 10
, you're saying "within every 10 similarly-relevant results, let sales break the tie." This works whether you have 50 results or 5000. So try with:
"_text_match(bucket_size: 10):desc,sales_count:desc"
2. You can also add conditional Boosting of the sales count with
_eval()
as this gives tiered boosts rather than linear ones, which might address your "don't blanket push all sold items" concern.
_text_match(bucket_size: 10):desc,_eval([(sales_count:>100):3, (sales_count:>10):2, (sales_count:>0):1]):desc
t
thanks for your reply. I notice you said something like _eval([(sales_count:>100):3 Whats the:3 bit ? ah I think its making 3 groups.. ok fair, but again the grouping varies based on the actual results.. you may have a result set with some with 1000s and others with 100s but another search may have only products with 10s or 0s so arbitrary groups cant be know before doing the search šŸ˜• My issue with buckets is - really I would want to decide on bucket size when I know the result size. I was also concerned that it makes all the results in the same bucket the same weight.. so random ordered ? like if you have 10,000 results and 10 buckets then suddenly 1000 results are all the same weight ? The normal weights of results in those 1000 may vary massively, in which case I wouldn't want them to be clumped as the same. I presume there are no min / max functions I can use in eval and also assume eval cant be used to return a result number and Add or subtract a value to the text result score
I believe you can pin results.. but can you say - pin the result with the most sales to a position? or better pin the top X results with most sales
Bucket size doesnt seem to do what I think it should. If I have 1000 results and _text_match(buckets:3)desc,sold totaldesc I seem to get about 50 products at the top which are secondarily ordered by sales.. then it resets, like there is a 50 bucket size but I said 3 buckets which should have a size more like 333
~I tried _text_match(bucket_size: 10):desc,_eval([(sales_count:>100):3, (sales_count:>10):2, (sales_count:>0):1]):desc but I get Error parsing eval expression in sort_by clause~
k
> like if you have 10,000 results and 10 buckets then suddenly 1000 results are all the same weight ? When you use
bucket_size
this won't be a problem. For e.g.
bucket_size: 10
will ensure that you split the results into groups of 10 hits. Also bucketing is applied only to the first 250 hits so it won't extend to the lower quality hits. Don't use
buckets
, use
bucket_size
.
t
Also bucketing is applied only to the first 250 hits
Oh, thanks. I can't see anywhere in the docs it says this. I also don't see anywhere its configurable? I tried changing max page size just in case and didnt seem to help. I seem to get no actual difference in order when I do buckets:10, buckets:2 or not at all šŸ˜• I will need to create a test though to show this I guess