When I ask the property “totalHits” on my TopDocs object, I get the number of hits.
But I want to know “how many” documents are found, not the “total hits”.
Example:
- document 1: field A: foo bar - field B: testjes
- document 2: field A: bar foo - field B: foo bar
If I search on “foo”, I will get 3 results when I ask for “docs.totalHits”.
But I want to know the number of documents, which is 2.
I could loop the list and save the “document ID” in a Set. And then ask the size of the Set, but does Lucene support a better way to solve this?
Jochen
As documented here you can retrieve it from your
TopDocCollectorusinggetTotalHits().Edit: For Example