SOLR-5204: StatsComponent and SpellCheckComponent do not support the shards.tolerant=true parameter

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1546819 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2013-12-01 15:06:42 +00:00
parent 1e26cb20ba
commit f56bf5b9d0
4 changed files with 46 additions and 4 deletions

View File

@ -169,6 +169,9 @@ Bug Fixes
* SOLR-5515: NPE when getting stats on date field with empty result on * SOLR-5515: NPE when getting stats on date field with empty result on
SolrCloud. (Alexander Sagen, shalin) SolrCloud. (Alexander Sagen, shalin)
* SOLR-5204: StatsComponent and SpellCheckComponent do not support the
shards.tolerant=true parameter. (Anca Kopetz, shalin)
Optimizations Optimizations
---------------------- ----------------------

View File

@ -320,7 +320,16 @@ public class SpellCheckComponent extends SearchComponent implements SolrCoreAwar
if (maxResultsForSuggest==null || !isCorrectlySpelled) { if (maxResultsForSuggest==null || !isCorrectlySpelled) {
for (ShardRequest sreq : rb.finished) { for (ShardRequest sreq : rb.finished) {
for (ShardResponse srsp : sreq.responses) { for (ShardResponse srsp : sreq.responses) {
NamedList nl = (NamedList) srsp.getSolrResponse().getResponse().get("spellcheck"); NamedList nl = null;
try {
nl = (NamedList) srsp.getSolrResponse().getResponse().get("spellcheck");
} catch (Exception e) {
if (rb.req.getParams().getBool(ShardParams.SHARDS_TOLERANT, false)) {
continue; // looks like a shard did not return anything
}
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Unable to read spelling info for shard: " + srsp.getShard(), e);
}
LOG.info(srsp.getShard() + " " + nl); LOG.info(srsp.getShard() + " " + nl);
if (nl != null) { if (nl != null) {
mergeData.totalNumberShardResponses++; mergeData.totalNumberShardResponses++;

View File

@ -102,7 +102,16 @@ public class StatsComponent extends SearchComponent {
StatsInfo si = rb._statsInfo; StatsInfo si = rb._statsInfo;
for (ShardResponse srsp : sreq.responses) { for (ShardResponse srsp : sreq.responses) {
NamedList stats = (NamedList) srsp.getSolrResponse().getResponse().get("stats"); NamedList stats = null;
try {
stats = (NamedList) srsp.getSolrResponse().getResponse().get("stats");
} catch (Exception e) {
if (rb.req.getParams().getBool(ShardParams.SHARDS_TOLERANT, false)) {
continue; // looks like a shard did not return anything
}
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Unable to read stats info for shard: " + srsp.getShard(), e);
}
NamedList stats_fields = (NamedList) stats.get("stats_fields"); NamedList stats_fields = (NamedList) stats.get("stats_fields");
if (stats_fields != null) { if (stats_fields != null) {

View File

@ -105,6 +105,8 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
t1,"no eggs on wall, lesson learned", t1,"no eggs on wall, lesson learned",
oddField, "odd man out"); oddField, "odd man out");
indexr(id, "1001", "lowerfilt", "toyota"); // for spellcheck
indexr(id, 14, "SubjectTerms_mfacet", new String[] {"mathematical models", "mathematical analysis"}); indexr(id, 14, "SubjectTerms_mfacet", new String[] {"mathematical models", "mathematical analysis"});
indexr(id, 15, "SubjectTerms_mfacet", new String[] {"test 1", "test 2", "test3"}); indexr(id, 15, "SubjectTerms_mfacet", new String[] {"test 1", "test 2", "test3"});
indexr(id, 16, "SubjectTerms_mfacet", new String[] {"test 1", "test 2", "test3"}); indexr(id, 16, "SubjectTerms_mfacet", new String[] {"test 1", "test 2", "test3"});
@ -227,6 +229,9 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
query("q","*:*", "fl", "id", "fl",nint, "fl",tint,"sort",i1 + " desc"); query("q","*:*", "fl", "id", "fl",nint, "fl",tint,"sort",i1 + " desc");
query("q","*:*", "fl",nint, "fl", "id", "fl",tint,"sort",i1 + " desc"); query("q","*:*", "fl",nint, "fl", "id", "fl",tint,"sort",i1 + " desc");
// basic spellcheck testing
query("q", "toyata", "fl", "id,lowerfilt", "spellcheck", true, "spellcheck.q", "toyata", "qt", "spellCheckCompRH_Direct", "shards.qt", "spellCheckCompRH_Direct");
stress=0; // turn off stress... we want to tex max combos in min time stress=0; // turn off stress... we want to tex max combos in min time
for (int i=0; i<25*RANDOM_MULTIPLIER; i++) { for (int i=0; i<25*RANDOM_MULTIPLIER; i++) {
String f = fieldNames[random().nextInt(fieldNames.length)]; String f = fieldNames[random().nextInt(fieldNames.length)];
@ -336,7 +341,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
assertNotNull("missing shard info", sinfo); assertNotNull("missing shard info", sinfo);
assertEquals("should have an entry for each shard ["+sinfo+"] "+shards, cnt, sinfo.size()); assertEquals("should have an entry for each shard ["+sinfo+"] "+shards, cnt, sinfo.size());
// test shards.tolerant=true // test shards.tolerant=true
for(int numDownServers = 0; numDownServers < jettys.size()-1; numDownServers++) for(int numDownServers = 0; numDownServers < jettys.size()-1; numDownServers++)
{ {
@ -383,6 +388,22 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
ShardParams.SHARDS_INFO, "true", ShardParams.SHARDS_INFO, "true",
ShardParams.SHARDS_TOLERANT, "true"); ShardParams.SHARDS_TOLERANT, "true");
queryPartialResults(upShards, upClients,
"q", "*:*",
"stats", "true",
"stats.field", i1,
ShardParams.SHARDS_INFO, "true",
ShardParams.SHARDS_TOLERANT, "true");
queryPartialResults(upShards, upClients,
"q", "toyata",
"spellcheck", "true",
"spellcheck.q", "toyata",
"qt", "spellCheckCompRH_Direct",
"shards.qt", "spellCheckCompRH_Direct",
ShardParams.SHARDS_INFO, "true",
ShardParams.SHARDS_TOLERANT, "true");
// restart the jettys // restart the jettys
for (JettySolrRunner downJetty : downJettys) { for (JettySolrRunner downJetty : downJettys) {
downJetty.start(); downJetty.start();
@ -409,7 +430,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
} }
} }
protected void queryPartialResults(final List<String> upShards, protected void queryPartialResults(final List<String> upShards,
final List<SolrServer> upClients, final List<SolrServer> upClients,
Object... q) throws Exception { Object... q) throws Exception {