Apache Lucene open-source search software
SOLR-5492: Added shardAddress in grouping query responses. Added tests.
Shalin Shekhar Mangarbee606588d3a
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.javaindex 8dea1d318ed..ce06e4f8155 100644--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java@@ -92,7 +92,9 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessorif (srsp.getSolrResponse() != null) {nl.add("time", srsp.getSolrResponse().getElapsedTime());}-+ if (srsp.getShardAddress() != null) {+ nl.add("shardAddress", srsp.getShardAddress());+ }shardInfo.add(srsp.getShard(), nl);}if (rb.req.getParams().getBool(ShardParams.SHARDS_TOLERANT, false) && srsp.getException() != null) {diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.javaindex 1f41b073979..dd9bdbb62cd 100644--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java@@ -108,7 +108,9 @@ public class TopGroupsShardResponseProcessor implements ShardResponseProcessor {if (srsp.getSolrResponse() != null) {individualShardInfo.add("time", srsp.getSolrResponse().getElapsedTime());}-+ if (srsp.getShardAddress() != null) {+ individualShardInfo.add("shardAddress", srsp.getShardAddress());+ }shardInfo.add(srsp.getShard(), individualShardInfo);}if (rb.req.getParams().getBool(ShardParams.SHARDS_TOLERANT, false) && srsp.getException() != null) {diff --git a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java b/solr/core/src/test/org/apache/solr/TestDistributedSearch.javaindex d0887f4f7c8..07655725e21 100644--- a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java+++ b/solr/core/src/test/org/apache/solr/TestDistributedSearch.java@@ -507,6 +507,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {// make sure that it responded if it's upif (upShards.contains(s)) {assertTrue("Expected to find numFound in the up shard info",info.get("numFound") != null);+ assertTrue("Expected to find shardAddress in the up shard info",info.get("shardAddress") != null);}else {assertTrue("Expected to find error in the down shard info",info.get("error") != null);diff --git a/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java b/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.javaindex a84c9ea99b3..50ec13b2c5b 100644--- a/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java@@ -57,6 +57,8 @@ import org.apache.solr.common.cloud.ZkNodeProps;import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.CollectionParams.CollectionAction;import org.apache.solr.common.params.ModifiableSolrParams;+import org.apache.solr.common.params.ShardParams;+import org.apache.solr.common.util.NamedList;import org.apache.solr.update.DirectUpdateHandler2;import org.apache.solr.util.DefaultSolrThreadFactory;import org.junit.Before;@@ -243,6 +245,16 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {assertEquals(0, collectionClient.query(new SolrQuery("*:*").setParam(_ROUTE_,"b")).getResults().getNumFound());assertEquals(3, collectionClient.query(new SolrQuery("*:*").setParam(_ROUTE_,"a")).getResults().getNumFound());+ // test shards.info with _route_ param+ QueryResponse resp = collectionClient.query(new SolrQuery("*:*").setParam(_ROUTE_, "a").setParam(ShardParams.SHARDS_INFO, true));+ NamedList<?> sinfo = (NamedList<?>) resp.getResponse().get(ShardParams.SHARDS_INFO);+ assertNotNull("missing shard info", sinfo);+ for (Map.Entry<String,?> entry : sinfo) {+ NamedList<?> info = (NamedList<?>) entry.getValue();+ assertTrue("Expected to find numFound in the up shard info",info.get("numFound") != null);+ assertTrue("Expected to find shardAddress in the up shard info",info.get("shardAddress") != null);+ }+collectionClient.deleteByQuery("*:*");collectionClient.commit(true,true);assertEquals(0, collectionClient.query(new SolrQuery("*:*")).getResults().getNumFound());