Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way for Solr/Lucene to return the ranks of selected documents instead of full results?

Tags:

solr

lucene

rank

I am interested in querying Solr with query q and charting its recall of a set of documents D when {10, 20, 30, ...} documents are returned.

Currently, I am having the full results, i.e. a list of docids returned (through solrpy), and iterate through it to find the ranks of D, i.e. a mapping from D to their indices in the search results. I do not strictly require the mapping, only mapped ranks.

Is there a way to have Solr/Lucene return ranks for a set of IDs instead of the full results?

Other ways of approaching this problem:

  • For a query, return the rank of document d
  • For a query up to a specified rank, return whether or not document d is present
  • From a query q1 result up to a specified number of records, return the number of records matched by another query q2
like image 884
joeln Avatar asked Oct 28 '11 01:10

joeln


2 Answers

You can retrieve rank by score field.

Append &fl=KeyFieldName,score to retrieve document id and score to your query. If you need all fields append &fl=*,score to your query.

See http://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_see_the_relevancy_scores_for_search_results for details.

like image 180
Matej Avatar answered Nov 04 '22 08:11

Matej


No I cannot think of a SOLR or Lucene way to do this. I think the simplest solution here is to program this yourself with a simple HashSet...

like image 42
Hugo Zaragoza Avatar answered Nov 04 '22 09:11

Hugo Zaragoza