2

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

Kp Gupta
  • 443
  • 1
  • 7
  • 22

3 Answers3

3

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

Andre85
  • 382
  • 2
  • 6
1

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.

David Faber
  • 11,549
  • 2
  • 25
  • 40
0

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.

Yavar
  • 11,773
  • 4
  • 28
  • 60
  • Thanks, i know about this. but we have an issue with some special cases. If we are searching for full phrase it should come on top but in some cases results is not coming on top. Don't know why? Can you help me with this? – Kp Gupta Mar 13 '12 at 12:02
  • LCS does not guarantee that exact phrase will be ranked higher. – Andre85 Jul 20 '16 at 08:57
  • By exact phrase i understand term match AND consecutive position matching. I'm not sure if LCS is used in Lucene, but if used, it does not ensure higher ranks for consecutive position term match, since tf-idf is used for scoring. If you want this behaviour, you'll need to use Lucene/Solr phrase queries, which take position information into account and increases score for documents that match this types of query. – Andre85 Jul 20 '16 at 09:26