I am working on a store search API using Lucene.
I need to show store search results for each City,State combination with its frequency in brackets....for example:
Los Angles,CA (450)
Atlanta,GA (212)
Boston, MA (78)
.
.
.
As of now, my search results return around 7000 Lucene documents, on average, if the user says "Show me all the stores". In this use case, I end up showing around 800 unique City,State records as shown above.
I am overriding the HitCollector
class's Collect
method and retrieving vectors as follows:
var vectors = _reader.GetTermFreqVectors(doc);
Then I iterate through this collection and calculate the frequency for each unique City,State combination.
But this is turning out to be very very slow in performance...is there any better way of grouping search results and calculating frequency in Lucene? A code snippet would be very helpful
Also, please suggest if I can optimize my Lucene search code using any other techniques/tips....
Thanks for reading!