SOLR-5535: Set partialResults header for shards that error out if shards.tolerant is specified

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1563576 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-02-02 07:47:51 +00:00
parent 584fda3bdf
commit 1da7b4b4c9
6 changed files with 19 additions and 0 deletions

View File

@ -160,6 +160,8 @@ New Features
* SOLR-5670: allow _version_ to use DocValues. (Per Steffensen via yonik)
* SOLR-5535: Set "partialResults" header for shards that error out if
shards.tolerant is specified. (Steve Davids via shalin)
Bug Fixes
----------------------

View File

@ -848,6 +848,7 @@ public class QueryComponent extends SearchComponent
}
// now that we've added the shard info, let's only proceed if we have no error.
if (srsp.getException() != null) {
partialResults = true;
continue;
}

View File

@ -308,6 +308,10 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware ,
} else {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, srsp.getException());
}
} else {
if(rsp.getResponseHeader().get("partialResults") == null) {
rsp.getResponseHeader().add("partialResults", Boolean.TRUE);
}
}
}

View File

@ -98,6 +98,9 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessor
shardInfo.add(srsp.getShard(), nl);
}
if (rb.req.getParams().getBool(ShardParams.SHARDS_TOLERANT, false) && srsp.getException() != null) {
if(rb.rsp.getResponseHeader().get("partialResults") == null) {
rb.rsp.getResponseHeader().add("partialResults", Boolean.TRUE);
}
continue; // continue if there was an error and we're tolerant.
}
maxElapsedTime = (int) Math.max(maxElapsedTime, srsp.getSolrResponse().getElapsedTime());

View File

@ -114,6 +114,9 @@ public class TopGroupsShardResponseProcessor implements ShardResponseProcessor {
shardInfo.add(srsp.getShard(), individualShardInfo);
}
if (rb.req.getParams().getBool(ShardParams.SHARDS_TOLERANT, false) && srsp.getException() != null) {
if(rb.rsp.getResponseHeader().get("partialResults") == null) {
rb.rsp.getResponseHeader().add("partialResults", Boolean.TRUE);
}
continue; // continue if there was an error and we're tolerant.
}
NamedList<NamedList> secondPhaseResult = (NamedList<NamedList>) srsp.getSolrResponse().getResponse().get("secondPhase");

View File

@ -510,6 +510,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
assertTrue("Expected to find shardAddress in the up shard info",info.get("shardAddress") != null);
}
else {
assertEquals("Expected to find the partialResults header set if a shard is down", Boolean.TRUE, rsp.getHeader().get("partialResults"));
assertTrue("Expected to find error in the down shard info",info.get("error") != null);
}
}
@ -518,4 +519,9 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
}
}
@Override
public void validateControlData(QueryResponse control) throws Exception {
super.validateControlData(control);
assertNull("Expected the partialResults header to be null", control.getHeader().get("partialResults"));
}
}