solr5 - Solr Boosting specific field values -
i'm trying boost score documents returned search in solr.
the boost want achieve along lines of:
field1:(value1)^5 or field2:(value2)^2
if document have field1 matching value1, boost 5. if document have field2 matching value2, boost 2.
the documents have many fields, let's call them field1, field2... , may missing fields.
the documents not need have field1 or field2 matching value1, value2 respectively.
i have other filter queries such as:
fq: field1:[* *] <- checking presence of fq: field3: ("something" "somethingelse") fq: field4: 1
i grouping results field not being used in of queries.
raw query parameters:
group=true&group.facet=true&group.field=anindependentfield
i using same fq's tried different query parsers.
there enough documents in solr field1:value1 and/or field2:value2 other values fields.
so far i've tried using query parsers:
- standard query parser
method a) q: field1:(value1)^5 or field2:(value2)^2 // no results
method b) q: *:* or field1:(value1)^5 or field2:(value2)^2 // no results
method c) q: (value1)^5 or (value2)^2 // incorrect. looks complete match.
method d) q: (value1)^5 (value2)^2 // incorrect. looks complete match
- edismax query parser
(deftype=edismax)
q: *:*
bq: field1:(value1)^5 or field2:(value2)^2
problem 1 results not in expected order. document has field1:somethingelse , field2:somethingelse2 got higher score document has field1: somethingelse , field2:value2.
can see i'm doing wrong or has suggestion improve relevancy of search queries?
you can use bf parameter of edismax queryparser in following way:
bf=if(termfreq(field1,"value1"),5,if(termfreq(field2,"value2"),2,1))
please find below complete query.
https://<my_server_name>:9443/solr/<my_collection>/select?q=*%3a*&wt=json&indent=true&deftype=edismax&bf=if(termfreq(field1%2c%22value1%22)%2c3%2cif(termfreq(field2%2c%22value2%22)%2c2%2c0))
Comments
Post a Comment