I'm trying to boost the score for documents returned from a search in solr.
The boost I want to achieve is something along the lines of:
field1:(value1)^5 OR field2:(value2)^2
If the document does have field1 matching value1, boost by 5. If document does have field2 matching value2, boost by 2.
The documents have many fields, let's call them field1, field2... and may be missing certain fields.
The documents do not need to have field1 or field2 matching value1, value2 respectively.
I have other filter queries such as:
fq: field1:[* TO *] <- checking for presence of
fq: field3: ("something" "somethingelse")
fq: field4: 1
I am grouping my results by a certain field not being used in any of the queries.
Raw query parameters:
group=true&group.facet=true&group.field=anIndependentField
I am using the same fq's with tried different query parsers.
There are enough documents in solr with field1:value1 and/or field2:value2 as well as other values for those fields.
So far I've tried using the 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 for complete match.
method d) q: (value1)^5 (value2)^2 // incorrect. looks for complete match
- EDisMax Query Parser
(defType=edismax)
q: *:*
bq: field1:(value1)^5 OR field2:(value2)^2
Problem with this one is that results are not in expected order. A document that has field1:somethingElse and field2:somethingElse2 got a higher score than a document that has field1: somethingElse and field2:value2.
Can anyone see what I'm doing wrong or has a suggestion to improve the relevancy of my search queries?
bq
argument?&bq=field1:value1^5&bq=field2:value2^2
– MatsLindh