I have a 'charges' field in my index . I want to boost results whose charges value is not equal to 0 . I tried using the bq parameter for this , but it did not work out .
&bq=charges:"0"^-1
I tried using the above , however I got a 400 error report .
In addition to the answer by @harmstyler
Instead of Boosting negatively, you can boost the the no zero values positively (if charges is an integer field) e.g.
bq=charges:[1 TO *]^10
This is old post but not quite updated, Negative boost is currently supported.
Below from Solr Documentation on negative boost:
Negative query boosts have been supported at the "Query" object level for a long time (resulting in negative scores for matching documents). Now the QueryParsers have been updated to handle this too.
Part resulting in negative scores for matching documents
might not always be true, as explained below.
Example usage: Considering your collection name is product_collection
and you want to bury(negative boost) product with specific brand:
http://localhost:8983/solr/product_collection/select?q=shoes&bq=brand:puma^-2&defType=dismax
This query will be parsed to:
"parsedquery_toString": "+((keyword:shoes)^1.0) () (brand:puma)^-2.0"
In this case, -2
factor will be multiplied to tf-idf score of (brand:puma)
match, resulting in lower score for documents containing brand puma
.
But, adding negative factor in boost query does not mean, it will always produce negative final score for document. For instance, if documents tf-idf score for keyword:shoes
match is 3.0
and tf-idf score of brand:puma
results in -1.5
, still the overall result will be 1.5(positive). So, use negative boost factor accordingly.
One such example from my own collection:
"\n3.4329534 = sum of:\n 6.151505 = weight(keyword:shoes in 5786) [SchemaSimilarity], result of:\n 6.151505 = score(doc=5786,freq=1.0 = termFreq=1.0\n), product of:\n 4.2804184 = idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:\n 199.0 = docFreq\n 14417.0 = docCount\n 1.437127 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:\n 1.0 = termFreq=1.0\n 1.2 = parameter k1\n 0.75 = parameter b\n 7.7978773 = avgFieldLength\n 2.0 = fieldLength\n -2.7185516 = weight(brand:puma in 5786) [SchemaSimilarity], result of:\n -2.7185516 = score(doc=5786,freq=1.0 = termFreq=1.0\n), product of:\n -2.0 = boost\n 1.3592758 = idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:\n 3704.0 = docFreq\n 14422.0 = docCount\n 1.0 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1) from:\n 1.0 = termFreq=1.0\n 1.2 = parameter k1\n 0.0 = parameter b (norms omitted for field)\n",
Score of keyword:shoes = 6.151505
Score of brand:puma = -2.7185516
Resulting in overall score positive score of 3.4329534
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With