Kp Gupta
Kp Gupta

Reputation: 483

How to increase the ranking of a search text in solr?

can any body please help us to know how to increase the releavncy of exact phrase in solr?

Upvotes: 2

Views: 1086

Answers (3)

Andre85
Andre85

Reputation: 469

If and only if you're using dismax, than you can just set the pf (Phrase Fields) parameter. It has the same syntax as the qf parameter: fieldName^boost

example:

fieldOne^2.3 fieldTwo fieldThree^0.4

this will boost phrase matches on the specified fields using the specified boosts. No boost value (as in fieldTwo) will use the default boost which is 1.0. If you use pf, you should also take a look at the ps (Phrase Slop) parameter, which specifies how far can two words be so that they still count as a "phrase".

Anyway, this link on DisMaxQParserPlugin should help

Upvotes: 3

David Faber
David Faber

Reputation: 12486

What you could do is add an OR to your query with the exact phrase, and then boost that phrase. For example, your query might be:

?q=(foo OR bar OR "foo bar"^10)

Results with "foo" or "bar" would still be found, but the exact phrase would be boosted.

The following page has some helpful information about this, including how to use query parsers other than the standard parser: http://solr.pl/en/2010/07/14/solr-and-phrasequery-phrase-bonus-in-query-stage/

Hope this helps.

Upvotes: 1

Yavar
Yavar

Reputation: 11933

Based on LCS Algorithm an exact match of the complete query string should automatically be ranked higher as compared to other matches. I think that should be the default behavior. There is concept of boosting and all in Solr however i dont think it will be required in this scenario.

Upvotes: 0

Related Questions