Im trying to use the BlockGroupingCollector to get grouped results when
searching in Lucene. I had indexed my doucments using the addDocuments function
in IndexWriter and also added a group separator at the end of each group.
Using this code:
val groupEndDocs = new TermQuery(new Term("groupEnd", "x"))
val c = new BlockGroupingCollector(Sort.RELEVANCE, 10, true,
groupEndDocs.createWeight(searcher, false))
searcher.search(customQuery, c)
val groupsResult = c.getTopGroups(Sort.INDEXORDER, 0, 0, 100, false)
Here customQuery is my query which uses custom scoring by overriding
getCustomScoreProvider. Now when i set needsScore in BlockGroupingCollector to
true what i observe is my custom scorer is being called twice for each
document. If i set it to false its fine and is being called only once. Its
quite expensive to call it again. So i cant understand that if withinGroup sort
is not be relevance why is it being called twice. I do need the scores for all
documents within a group. How do i get them with calling my scorer only once?
Thanks.