Forming a search result
By now, we have seen various examples of searches, but we haven't yet talked about search results in detail. Let's take a look at what we get in return when we perform a search. In IndexSearcher
, there are several ways to submit a search. You can search by Query, with a Filter and Sort. You may notice that there is also an int
field in which to specify the maximum number of results to return. This value is useful when you implement pagination. The return object from the search method is TopDocs. TopDocs has two attributes, an array of ScoreDoc
and totalHits
. The ScoreDoc
contains DocId and score. totalHits
is the total number of matching documents in this search. Note that the max results int
value has no effect on totalHits
as totalHits
is the overall count of the matching documents.
As you may have noticed, the results returned from the search are just a list of pointers (DocId) and their scores. We don't actually get any document content from search. To retrieve...