3

How can I boost a query by a string field? I've found only resources explaining date boosting.

E.g. these documents should be boosted in this order:

  1. priority=a
  2. priority=b
  3. priority=c

I know, that I could sort by priority, but I want to combine this field with the solr relevancy mechanisms.

Matthias M
  • 12,906
  • 17
  • 87
  • 116

2 Answers2

2

The solution is a boost function using rord()

bf=rord(priority)^10

rord maps a string to an integer, which can then be used for boosting.

Matthias M
  • 12,906
  • 17
  • 87
  • 116
1

If you want to apply custom weights to each value; i.e. say that b is two times more important than a, or that your priorities aren't necessarily ordered (i.e. c should be boosted more than b, but not more than a), you can add a boost query with each weight:

bq=priority:a^10 priority:b^2 priority:c^5
MatsLindh
  • 49,529
  • 4
  • 53
  • 84