views:

127

answers:

1

I need to show total documents count for each category in my search results...for example: Rock(1010) Blues(5030) Pop(2209) : :

I was reading somewhere that using TopFieldDocCollector is more efficient than HitCollector class.

Given my requirement, how do I use TopFieldDocCollector class?or is there any other approach in Lucene?

+1  A: 

HitCollector is an abstract class. TopDocCollector and TopFieldDocCollector are implementations of that class. They can't be "more efficient" because there's no actual code in HitCollector. As for the difference between TopDocCollector and TopFieldDocCollector - the former is used when you want to sort the results by relevance and the latter is for when you want a custom sort.

Now, regarding your question, check out my answer to a similar question.

itsadok