LUCENE-4581: GroupingSearch.setAllGroups(true) was failing to compute allMatchingGroups

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1415993 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2012-12-01 13:30:01 +00:00
parent 5aacb271b2
commit 232f38b65d
3 changed files with 31 additions and 3 deletions

View File

@ -182,6 +182,10 @@ Bug Fixes
* LUCENE-4568: Fixed integer overflow in
PagedBytes.PagedBytesData{In,Out}put.getPosition. (Adrien Grand)
* LUCENE-4581: GroupingSearch.setAllGroups(true) was failing to
actually compute allMatchingGroups (dizh@neusoft.com via Mike
McCandless)
Optimizations
* LUCENE-2221: oal.util.BitUtil was modified to use Long.bitCount and

View File

@ -210,7 +210,7 @@ public class GroupingSearch {
if (allGroupHeads || allGroups) {
List<Collector> collectors = new ArrayList<Collector>();
collectors.add(firstPassCollector);
if (allGroupHeads) {
if (allGroups) {
collectors.add(allGroupsCollector);
}
if (allGroupHeads) {
@ -403,7 +403,7 @@ public class GroupingSearch {
}
/**
* Whether to also co0.0mpute all groups matching the query.
* Whether to also compute all groups matching the query.
* This can be used to determine the number of groups, which can be used for accurate pagination.
* <p/>
* When grouping by doc block the number of groups are automatically included in the {@link TopGroups} and this

View File

@ -227,5 +227,29 @@ public class GroupingSearchTest extends LuceneTestCase {
return groupingSearch;
}
public void testSetAllGroups() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(
random(),
dir,
newIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy()));
Document doc = new Document();
doc.add(newField("group", "foo", StringField.TYPE_NOT_STORED));
w.addDocument(doc);
IndexSearcher indexSearcher = new IndexSearcher(w.getReader());
w.close();
GroupingSearch gs = new GroupingSearch("group");
gs.setAllGroups(true);
TopGroups<?> groups = gs.search(indexSearcher, null, new TermQuery(new Term("group", "foo")), 0, 10);
assertEquals(1, groups.totalHitCount);
//assertEquals(1, groups.totalGroupCount.intValue());
assertEquals(1, groups.totalGroupedHitCount);
assertEquals(1, gs.getAllMatchingGroups().size());
indexSearcher.getIndexReader().close();
dir.close();
}
}