From 92176fce6e122994337da6794f405d09d74e2189 Mon Sep 17 00:00:00 2001 From: "Chris M. Hostetter" Date: Thu, 13 Dec 2012 20:38:52 +0000 Subject: [PATCH] grouping tests of case where no docs match main query. written while trying to repro SOLR-4164, but something is still missing git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1421505 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/solr/TestDistributedGrouping.java | 12 ++++++++ .../org/apache/solr/TestGroupingSearch.java | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java b/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java index 6ee40a28e67..8d4ffcda716 100755 --- a/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java +++ b/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java @@ -175,6 +175,18 @@ public class TestDistributedGrouping extends BaseDistributedSearchTestCase { "group.query", t1 + ":this_will_never_match", "group.limit", 10, "sort", i1 + " asc, id asc"); + // SOLR-4164: main query matches nothing, or only matches on one shard + query("q", "bogus_s:nothing", // no docs match + "group", "true", + "group.query", t1 + ":this_will_never_match", + "group.field", i1, + "fl", "id", "group.limit", "2", "group.format", "simple"); + query("q", "id:5", // one doc matches, so only one shard + "rows", 100, "fl", "id," + i1, "group", "true", + "group.query", t1 + ":kings OR " + t1 + ":eggs", + "group.field", i1, + "group.limit", 10, "sort", i1 + " asc, id asc"); + // SOLR-3109 query("q", t1 + ":eggs", "rows", 100, "fl", "id," + i1, "group", "true", "group.field", i1, "group.limit", 10, "sort", tlong + " asc, id asc"); query("q", i1 + ":232", "rows", 100, "fl", "id," + i1, "group", "true", "group.field", i1, "group.limit", 10, "sort", tlong + " asc, id asc"); diff --git a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java b/solr/core/src/test/org/apache/solr/TestGroupingSearch.java index d902474e898..98c6ebee779 100644 --- a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java +++ b/solr/core/src/test/org/apache/solr/TestGroupingSearch.java @@ -585,6 +585,34 @@ public class TestGroupingSearch extends SolrTestCaseJ4 { , "/grouped/foo_i=={'matches':10,'doclist':" + "{'numFound':10,'start':1,'docs':[{'id':'10'},{'id':'3'},{'id':'6'}]}}" ); + + //////////////////////// grouping where main query matches nothing + assertJQ(req("fq", filt, "q", "bogus_s:nothing", "group", "true", "group.field", f, "fl", "id", "group.limit", "2", "group.format", "simple") + , "/grouped/foo_i=={'matches':0,'doclist':{'numFound':0,'start':0,'docs':[]}}" + ); + assertJQ(req("fq",filt, "q","bogus_s:nothing", "group","true", + "group.query","id:[2 TO 5]", + "group.query","id:[5 TO 5]", + "group.field",f, + "rows","1", + "fl","id", "group.limit","2") + ,"/grouped/id:[2 TO 5]=={'matches':0,'doclist':{'numFound':0,'start':0,'docs':[]}}" + ,"/grouped/id:[5 TO 5]=={'matches':0,'doclist':{'numFound':0,'start':0,'docs':[]}}" + ,"/grouped/"+f+"=={'matches':0,'groups':[]}" + ); + assertJQ(req("fq",filt, + "q","bogus_s:nothing", + "group","true", + "group.query","id:[2 TO 5]", + "group.query","id:1000", + "fl","id", + "group.limit","3") + ,"/grouped/id:[2 TO 5]=={'matches':0,'doclist':{'numFound':0,'start':0,'docs':[]}}" + ,"/grouped/id:1000=={'matches':0,'doclist':{'numFound':0,'start':0,'docs':[]}}" + ); + + + }