Is there a way for Solr/Lucene to return the ranks

2019-06-16 20:45发布

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

标签: solr lucene rank
2条回答
我命由我不由天
2楼-- · 2019-06-16 20:54

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...

查看更多
乱世女痞
3楼-- · 2019-06-16 21:02

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.

查看更多
登录 后发表回答