I have a model, say Post. It has tags. Each of the tags has a weight that should be reflected in search. Can I somehow store these tags and boost each of them with its weight?
Example:
Post title is "Eating outside" Tags are "burgers" (weight 5), "pizza" (wight 4) and "sushi" (weight 2). When someone searches for "burgers", this should consider the extra boost and show it above a post with tag "burgers" which has weight=2.
First solution that came to my mind was having 5 text fields with boosts 1-5, that will contain the tags for each post. Is there more elegant solution?
There is no good out of the box support for that. However, the nearest match seems to be payloads. Have a look at the (oldish) article about it here but there is a more recent one as well. Both of these use custom similarity, which is quite an advanced topic. Fortunately, as of Solr 4, there is a way to define per-field similarity, so the final code may be simpler than any of those examples.
If you do figure this out, share the article with the rest of the world (e.g. at SearchHub). I think nobody has put the pieces together yet with fully updated Solr stack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With