0

Lets say my MaxScore is 500.

Then I want results with 500's 80% and above Score results only .

How can I achieve that?

Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47
  • try this...q=SEARCH_PHRASE &fq={!frange l=400.0}query($q,0) – Abhijit Bashetti Nov 27 '20 at 11:13
  • other option is sort by _score desc and apply the limit ...this is the simple approach – Abhijit Bashetti Nov 27 '20 at 11:14
  • @AbhijitBashetti Can you Explain this Function Query? – akshay kale Nov 27 '20 at 11:25
  • its the function range query parser...https://lucene.apache.org/solr/guide/7_5/other-parsers.html – Abhijit Bashetti Nov 27 '20 at 11:28
  • 2
    In general you should not rely on the score values - if you're seeing less relevant results, evaluate why they're included in the result at all. – MatsLindh Nov 27 '20 at 12:02
  • @MatsLindh I have lots of data So I'm trying to to limit it to Limit it to top 20% OR 40% relevant docs – akshay kale Nov 27 '20 at 14:19
  • 2
    That's not what you're asking for, though. In your question you'll end up with just one document if one document scores 25% higher than the second document (i.e. only the documents that score at least 80% of the top score). If you want to drop 80% _of the documents_, you'll have to make two queries - one to retrieve the number of documents in total, then a second query with `rows` set to 20% of that. A 20% difference in score is a very narrow range. – MatsLindh Nov 27 '20 at 19:22

2 Answers2

0

I would suggest to use _score as sorting by descending order and apply the limits by using start and rows.

?q=test&&start=0&rows=10&fl=_score

The other option is to use the function range query parser by reading the documentation provided at solr function range query

for example :

1. {!frange l=400 u=500}nameOfField

2. ​fq={!frange l=400 u=500} sum(field1,field2)
Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47
0

Function range query parser is the better way. If you use facets you get the right result count of facets.

This example is meant to be supplementary if edismax is used as defType fq={!frange l=400}query({!edismax v=$q})

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 29 '22 at 08:56