SOLR-7518: make facet module support shards.tolerant

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1683569 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2015-06-04 15:01:23 +00:00
parent 25a822bbb1
commit ae5a65e4b9
3 changed files with 45 additions and 10 deletions

View File

@ -97,6 +97,9 @@ Bug Fixes
* SOLR-7616: Faceting on a numeric field with a unique() subfacet function on another numeric field * SOLR-7616: Faceting on a numeric field with a unique() subfacet function on another numeric field
can result in incorrect results or an exception. (yonik) can result in incorrect results or an exception. (yonik)
* SOLR-7518: New Facet Module should respect shards.tolerant and process all non-failing shards
instead of throwing an exception. (yonik)
Optimizations Optimizations
---------------------- ----------------------

View File

@ -169,6 +169,7 @@ public class FacetModule extends SearchComponent {
for (ShardResponse shardRsp : sreq.responses) { for (ShardResponse shardRsp : sreq.responses) {
SolrResponse rsp = shardRsp.getSolrResponse(); SolrResponse rsp = shardRsp.getSolrResponse();
NamedList<Object> top = rsp.getResponse(); NamedList<Object> top = rsp.getResponse();
if (top == null) continue; // shards.tolerant=true will cause this to happen on exceptions/errors
Object facet = top.get("facets"); Object facet = top.get("facets");
if (facet == null) continue; if (facet == null) continue;
if (facetState.merger == null) { if (facetState.merger == null) {

View File

@ -174,18 +174,23 @@ public class TestJsonFacets extends SolrTestCaseHS {
} }
public void indexSimple(Client client) throws Exception {
client.deleteByQuery("*:*", null);
client.add(sdoc("id", "1", "cat_s", "A", "where_s", "NY", "num_d", "4", "num_i", "2", "val_b", "true", "sparse_s", "one"), null);
client.add(sdoc("id", "2", "cat_s", "B", "where_s", "NJ", "num_d", "-9", "num_i", "-5", "val_b", "false"), null);
client.add(sdoc("id", "3"), null);
client.commit();
client.add(sdoc("id", "4", "cat_s", "A", "where_s", "NJ", "num_d", "2", "num_i", "3"), null);
client.add(sdoc("id", "5", "cat_s", "B", "where_s", "NJ", "num_d", "11", "num_i", "7", "sparse_s", "two"),null);
client.commit();
client.add(sdoc("id", "6", "cat_s", "B", "where_s", "NY", "num_d", "-5", "num_i", "-5"),null);
client.commit();
}
public void testStatsSimple() throws Exception { public void testStatsSimple() throws Exception {
assertU(delQ("*:*")); Client client = Client.localClient();
assertU(add(doc("id", "1", "cat_s", "A", "where_s", "NY", "num_d", "4", "num_i", "2", "val_b", "true", "sparse_s","one"))); indexSimple(client);
assertU(add(doc("id", "2", "cat_s", "B", "where_s", "NJ", "num_d", "-9", "num_i", "-5", "val_b", "false")));
assertU(add(doc("id", "3")));
assertU(commit());
assertU(add(doc("id", "4", "cat_s", "A", "where_s", "NJ", "num_d", "2", "num_i", "3")));
assertU(add(doc("id", "5", "cat_s", "B", "where_s", "NJ", "num_d", "11", "num_i", "7", "sparse_s","two")));
assertU(commit());
assertU(add(doc("id", "6", "cat_s", "B", "where_s", "NY", "num_d", "-5", "num_i", "-5")));
assertU(commit());
// test multiple json.facet commands // test multiple json.facet commands
assertJQ(req("q", "*:*", "rows", "0" assertJQ(req("q", "*:*", "rows", "0"
@ -1039,7 +1044,33 @@ public class TestJsonFacets extends SolrTestCaseHS {
} }
public void testTolerant() throws Exception {
initServers();
Client client = servers.getClient(random().nextInt());
client.queryDefaults().set("shards", servers.getShards() + ",[ff01::114]:33332:/ignore_exception");
indexSimple(client);
try {
client.testJQ(params("ignore_exception", "true", "shards.tolerant", "false", "q", "*:*"
, "json.facet", "{f:{type:terms, field:cat_s}}"
)
, "facets=={ count:6," +
"f:{ buckets:[{val:B,count:3},{val:A,count:2}] }" +
"}"
);
fail("we should have failed");
} catch (Exception e) {
// ok
}
client.testJQ(params("ignore_exception", "true", "shards.tolerant", "true", "q", "*:*"
, "json.facet", "{f:{type:terms, field:cat_s}}"
)
, "facets=={ count:6," +
"f:{ buckets:[{val:B,count:3},{val:A,count:2}] }" +
"}"
);
}
public void XtestPercentiles() { public void XtestPercentiles() {
AVLTreeDigest catA = new AVLTreeDigest(100); AVLTreeDigest catA = new AVLTreeDigest(100);