Mason G. Zhwiti
Mason G. Zhwiti

Reputation: 6540

How can I do a Solr search where each keyword is weighted individually?

I see how you can use query functions to apply different weights to different fields being searched, but is there a way in Solr to weight the individual keywords being searched individually, so that the score can incorporate the weighting and rank my results based on that?

Imagine a search for:

lebron james basketball heat

Where lebron and james are weighted at 1.0, basketball is weighted at 0.9, and heat is weighted at 0.5.

If there isn't a way built-in to standard Solr, can you point me in the right direction for writing a plugin where I could build this functionality? Thanks!

Upvotes: 1

Views: 517

Answers (1)

c.hill
c.hill

Reputation: 3233

You can do a boost for each part of your query like this:

q=(lebron james)^100 (basketball)^90 (heat)^50

Upvotes: 2

Related Questions