You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2016/10/31 14:05:56 UTC
[03/37] lucene-solr:jira/solr-8542-v2: SOLR-9654: tests: fix
overrequest test by fixing doc->shard mapping
SOLR-9654: tests: fix overrequest test by fixing doc->shard mapping
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/53507b4e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/53507b4e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/53507b4e
Branch: refs/heads/jira/solr-8542-v2
Commit: 53507b4e79573af3fdc64207b9e47d62f7c99028
Parents: e448360
Author: yonik <yo...@apache.org>
Authored: Wed Oct 26 18:35:09 2016 -0400
Committer: yonik <yo...@apache.org>
Committed: Wed Oct 26 18:35:09 2016 -0400
----------------------------------------------------------------------
.../solr/search/facet/TestJsonFacets.java | 94 ++++++++++++--------
.../java/org/apache/solr/SolrTestCaseHS.java | 1 +
2 files changed, 59 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/53507b4e/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java
index c8ed0e6..5527a3d 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java
@@ -27,6 +27,7 @@ import java.util.Random;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import com.tdunning.math.stats.AVLTreeDigest;
+import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.common.SolrException;
import org.apache.solr.util.hll.HLL;
import org.apache.lucene.util.LuceneTestCase;
@@ -1146,47 +1147,68 @@ public class TestJsonFacets extends SolrTestCaseHS {
"} "
);
+ client.testJQ(params(p, "q", "*:*"
+ , "json.facet", "{" +
+ // "cat0:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:0}" + // overrequest=0 test needs predictable layout
+ "cat1:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:1}" +
+ ",catDef:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:-1}" + // -1 is default overrequest
+ ",catBig:{type:terms, field:${cat_s}, sort:'count desc', offset:1, limit:2147483647, overrequest:2147483647}" + // make sure overflows don't mess us up
+ "}"
+ )
+ , "facets=={ count:6" +
+ // ", cat0:{ buckets:[ {val:B,count:3} ] }"
+ ", cat1:{ buckets:[ {val:B,count:3} ] }" +
+ ", catDef:{ buckets:[ {val:B,count:3} ] }" +
+ ", catBig:{ buckets:[ {val:A,count:2} ] }" +
+ "}"
+ );
-/*
- if (!client.local()) {
- client.testJQ(params(p, "q", "*:*"
- , "json.facet", "{" +
- "cat0:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:0}" +
- ",cat1:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:1}" +
- ",catDef:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:-1}" + // -1 is default overrequest
- ",catBig:{type:terms, field:${cat_s}, sort:'count desc', offset:1, limit:2147483647, overrequest:2147483647}" + // make sure overflows don't mess us up
- "}"
- )
- , "facets=={ count:6" +
- ", cat0:{ buckets:[ {val:A,count:2} ] }" + // with no overrequest, we incorrectly conclude that A is the top bucket
- ", cat1:{ buckets:[ {val:B,count:3} ] }" +
- ", catDef:{ buckets:[ {val:B,count:3} ] }" +
- ", catBig:{ buckets:[ {val:A,count:2} ] }" +
- "}"
- );
- } else {
- // In non-distrib mode, should still be able to specify overrequest, but it shouldn't matter.
- client.testJQ(params(p, "q", "*:*"
- , "json.facet", "{" +
- "cat0:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:0}" +
- ",cat1:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:1}" +
- ",catDef:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:-1}" + // -1 is default overrequest
- ",catBig:{type:terms, field:${cat_s}, sort:'count desc', offset:1, limit:2147483647, overrequest:2147483647}" + // make sure overflows don't mess us up
- "}"
- )
- , "facets=={ count:6" +
- ", cat0:{ buckets:[ {val:B,count:3} ] }" + // only change from distrib-mode test above
- ", cat1:{ buckets:[ {val:B,count:3} ] }" +
- ", catDef:{ buckets:[ {val:B,count:3} ] }" +
- ", catBig:{ buckets:[ {val:A,count:2} ] }" +
- "}"
- );
- }
-*/
}
+ @Test
+ public void testOverrequest() throws Exception {
+ initServers();
+ Client client = servers.getClient(random().nextInt());
+ client.queryDefaults().set( "shards", servers.getShards(), "debugQuery", Boolean.toString(random().nextBoolean()) );
+
+ List<SolrClient> clients = client.getClientProvider().all();
+ assertTrue(clients.size() >= 3);
+
+ client.deleteByQuery("*:*", null);
+
+ ModifiableSolrParams p = params("cat_s", "cat_s");
+ String cat_s = p.get("cat_s");
+
+ clients.get(0).add( sdoc("id", "1", cat_s, "A") ); // A will win tiebreak
+ clients.get(0).add( sdoc("id", "2", cat_s, "B") );
+
+ clients.get(1).add( sdoc("id", "3", cat_s, "B") );
+ clients.get(1).add( sdoc("id", "4", cat_s, "A") ); // A will win tiebreak
+ clients.get(2).add( sdoc("id", "5", cat_s, "B") );
+ clients.get(2).add( sdoc("id", "6", cat_s, "B") );
+
+ client.commit();
+
+ // Shard responses should be A=1, A=1, B=2, merged should be "A=2, B=2" hence A wins tiebreak
+
+ client.testJQ(params(p, "q", "*:*",
+ "json.facet", "{" +
+ "cat0:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:0}" +
+ ",cat1:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:1}" +
+ ",catDef:{type:terms, field:${cat_s}, sort:'count desc', limit:1, overrequest:-1}" + // -1 is default overrequest
+ ",catBig:{type:terms, field:${cat_s}, sort:'count desc', offset:1, limit:2147483647, overrequest:2147483647}" + // make sure overflows don't mess us up
+ "}"
+ )
+ , "facets=={ count:6" +
+ ", cat0:{ buckets:[ {val:A,count:2} ] }" + // with no overrequest, we incorrectly conclude that A is the top bucket
+ ", cat1:{ buckets:[ {val:B,count:4} ] }" +
+ ", catDef:{ buckets:[ {val:B,count:4} ] }" +
+ ", catBig:{ buckets:[ {val:A,count:2} ] }" +
+ "}"
+ );
+ }
@Test
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/53507b4e/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java
index 118c194..aba2603 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseHS.java
@@ -285,6 +285,7 @@ public class SolrTestCaseHS extends SolrTestCaseJ4 {
public boolean local() {
return provider == null;
}
+ public ClientProvider getClientProvider() { return provider; }
public void testJQ(SolrParams args, String... tests) throws Exception {
if (queryDefaults != null) {