Slackbot
06/20/2023, 1:59 PMJohn
06/20/2023, 3:20 PM_eval. I created a collection with
[
{"title": "Heavy Cream", "product_id": "1"},
{"title": "Cream", "product_id": "2"},
{"title": "Best Cream", "product_id": "3"},
{"title": "Wow I love this cream", "product_id": "4"},
]
which normally would give
Cream
Wow I love this cream
Best Cream
Heavy Cream
for "cream", but if you set
"sort_by": "_eval(product_id:[1,4]):desc,_text_match:desc"
you get
Wow I love this cream <- favorite
Heavy Cream <- favorite
Cream
Best Cream
There could be some performance costs if the user has a lot of favorites, but in my experience with large filters it hasn't been a problem even with many hundreds of items.
Note that this can result in worse matches marked as favorite coming before better matches, but I don't think it'll be much of a problem in practice (most of the time the entire candidate set will be quite good)Julian
06/20/2023, 3:58 PMJason Bosco
06/20/2023, 4:11 PMJason Bosco
06/20/2023, 4:13 PMfavorited_by_user_ids to each record, and store which users have favorited each product.
Then you could do something like this:
"sort_by": "_eval(favorited_by_user_ids:=<CURRENT_USERS_ID>):desc,_text_match:desc"Jason Bosco
06/20/2023, 4:14 PM