Display the results.
To view the results we need to loop through the ScoreDoc array we created in Part3. We do this by iterating through it within a for loop.
for (int i = 0; i < hits.Length; i++)
{
int docId = hits[i].doc;
float score = hits[i].score;
Lucene.Net.Documents.Document doc = searcher.Doc(docId);
string result = "Score: " + score.ToString() +
" Field: " + doc.Get("fieldName") +
" Field2: " + doc.Get("TERM");
}
That’s it. Follow these steps and you will have implemented a very powerful search capability.