Dear Wiki user, You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.
The "SolrRelevancyFAQ" page has been changed by HossMan: http://wiki.apache.org/solr/SolrRelevancyFAQ?action=diff&rev1=20&rev2=21 Comment: elaborate on negative boosts }}} Consider using reduced precision to prevent excessive memory consumption. You would instead use '''recip(ms(NOW/HOUR,mydatefield),3.16e-11,1,1)'''. See [[http://search-lucene.com/m/nkgRTTSRos1/FunctionQueries+and+FieldCache+and+OOM&subj=FunctionQueries+and+FieldCache+and+OOM|this thread]] for more information. - == How do I give a very low boost to documents that match my query == + == How do I give a negative (or very low) boost to documents that match a query? == - In general the problem is that a "low" boost is still a boost, it can only improve the score of documents that match. One way to fake a "negative boost" is to give a high boost to everything that does *not* match. For example: - . bq=(*:* -field_a:54)^10000 + True negative boosts are not supported, but you can use a very "low" numeric boost value on query clauses. In general the problem that confuses people is that a "low" boost is still a boost, it can only improve the score of documents that match. For example, if you want to find all docs matching "foo" or "bar" but penalize the scores of documents matching "xxx" you might be tempted to try... - TODO: If "bq" supports pure negative queries then you can simplify that to bq=-field_a:54^10000 + {{{ + q = foo^100 bar^100 xxx^0.00001 # NOT WHAT YOU WANT + }}} + + ...but this will still help a document matching all three clauses score higher then a document matching only the first two. One way to fake a "negative boost" is to give a large boost to everything that does *not* match. For example... + + + {{{ + q = foo^100 bar^100 (*:* -xxx)^999 + }}} + + '''NOTE:''' When using (e)dismax, people sometimes expect that specifying a pure negative query with a large boost in the "bq" param will work (since Solr automatically makes top level purely negative positive queries by adding an implicit "*:*" -- but this doesn't work with "bq", because of how queries specified via "bq" are added directly to the main query. You need to be explicit... + + {{{ + ? defType = dismax + & q = foo bar + & bq = (*:* -xxx)^999 + }}} == TODO == /!\ :TODO: /!\