5
votes

So each SOLR search result has their own relevancy score:

https://wiki.apache.org/solr/SolrRelevancyFAQ

"How can I see the relevancy scores for search results

Request that the pseudo-field named "score" be returned by adding it to the fl (field list) parameter. The "score" will then appear along with the stored fields in returned documents. q=Justice League&fl=*,score"

My question is...is it possible to filter SOLR results by this relevancy score?

Eg. perform a query in the nature of the following

Search for keyword "LOL" and only fetch documents whose relevancy score > 50

If it's possible how would you go about specifying this query syntactically?

3

3 Answers

3
votes

I spent hours trying to filter out values with a relevance score of 0. I couldn't find any straight forward way to do this. I ended up accomplishing this with a workaround that assigns the query function to a local param. I call this local param in both the query ("q=") and the filter query ("fq=").

Example

Let's say you have a query like:

q={!func}sum(*your arguments*)

First, make the function component its own parameter:

q={!func}$localParam
&localParam={!func}sum(*your arguments*)

Now to only return results with scores between 1 and 10 simply add a filter query on that localParam:

q={!func}$localParam
&localParam={!func}sum(*your arguments*)
&fq={!frange l=1 u=10 inclusive=true}$localParam
2
votes

You can specify a maximum number of results to return. The results will appear in descending order by score, so you could stop processing at a specific point in the result set.

solr/search/select?q=LOL&&start=0&rows=10&fl=*%2Cscore

See the following article for a discussion about setting a minimum score: Is it possible to set a Solr Score threshold 'reasonably', independent of results returned? (i.e. Is Solr Scoring standardized in any way)

1
votes

solr 6.6:

add a solr filter query (fq):

q=SEARCH_PHRASE
&fq={!frange l=50.0}query($q,0)

in this case solr will return the result with "score" >= 50.0

$q in query($q,0) - it's like a reference to a q parameter