Hi, If you only want to get that information for a single, certain document, you can use the "explain" functionality - but you need the internal document ID for that. Alternatively execute the query once (for whole result set) and an additional time with a filter on your external ID applied. The only result would be the filtered document, but with the same score as in first result set.
Uwe ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de > -----Original Message----- > From: Anton [mailto:anton.te...@gmail.com] > Sent: Wednesday, January 06, 2016 10:27 AM > To: general@lucene.apache.org > Subject: find out rank of document within a lucene query (with custom > sorting) > > Hi, > > I am interested to find out what rank a document holds within a search > query among all documents within the index. > > In more detail: I would like to create a query with a sorting. But I am not > interested in getting, for instance, the top 10 search hits for that query > and sorting. I am only interested what rank a certain document from the > index would be in the result of that query and sorting. It could be the > 42nd from 1024 documents in that result. I could identify the document via > an ID field. > > Is there a possibility to do get that rank number efficiently? > (A simple, but probably time consuming, solution would be: Get all > documents according to query and sorting. Loop through the result list and > find the specific document. Return the counter of the loop.) > > Here is a similar question on stackoverflow (without a satisfying answer): > http://stackoverflow.com/questions/7924146/is-there-a-way-for-solr- > lucene-to-return-the-ranks-of-selected-documents-instead > > Have a nice day, > Anton.