SOLR-5502: A "/" in a document id will cause an exception to be thrown when using the composite id router.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1547452 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-12-03 16:10:58 +00:00
parent 09aa2dce76
commit 1f57856b90
4 changed files with 21 additions and 18 deletions

View File

@ -189,6 +189,9 @@ Bug Fixes
* SOLR-5527: DIH logs spurious warning for special commands. (shalin)
* SOLR-5502: A "/" in a document id will cause an exception to be thrown
when using the composite id router. (Anshum Gupta via Mark Miller)
Optimizations
----------------------
@ -220,9 +223,6 @@ Other Changes
* SOLR-5499: Log a warning if /get is not registered when using SolrCloud.
(Daniel Collins via shalin)
* SOLR-5517: Return HTTP error on POST requests with no Content-Type.
(Ryan Ernst, Uwe Schindler)
================== 4.6.0 ==================
Versions of Major Components

View File

@ -148,30 +148,33 @@ public class ShardRoutingTest extends AbstractFullDistribZkTestBase {
doAddDoc("d!doc3");
doAddDoc("e!doc4");
doAddDoc("f1!f2!doc5");
// Check successful addition of a document with a '/' in the id part.
doAddDoc("f1!f2!doc5/5");
doRTG("b!doc1");
doRTG("c!doc2");
doRTG("d!doc3");
doRTG("e!doc4");
doRTG("f1!f2!doc5");
doRTG("f1!f2!doc5/5");
doRTG("b!doc1,c!doc2");
doRTG("d!doc3,e!doc4");
commit();
doQuery("b!doc1,c!doc2,d!doc3,e!doc4,f1!f2!doc5", "q","*:*");
doQuery("b!doc1,c!doc2,d!doc3,e!doc4,f1!f2!doc5", "q","*:*", "shards","shard1,shard2,shard3,shard4");
doQuery("b!doc1,c!doc2,d!doc3,e!doc4,f1!f2!doc5", "q","*:*", shardKeys,"b!,c!,d!,e!,f1!f2!");
doQuery("b!doc1,c!doc2,d!doc3,e!doc4,f1!f2!doc5,f1!f2!doc5/5", "q","*:*");
doQuery("b!doc1,c!doc2,d!doc3,e!doc4,f1!f2!doc5,f1!f2!doc5/5", "q","*:*", "shards","shard1,shard2,shard3,shard4");
doQuery("b!doc1,c!doc2,d!doc3,e!doc4,f1!f2!doc5,f1!f2!doc5/5", "q","*:*", shardKeys,"b!,c!,d!,e!,f1!f2!");
doQuery("b!doc1", "q","*:*", shardKeys,"b!");
doQuery("c!doc2", "q","*:*", shardKeys,"c!");
doQuery("d!doc3,f1!f2!doc5", "q","*:*", shardKeys,"d!");
doQuery("d!doc3,f1!f2!doc5,f1!f2!doc5/5", "q","*:*", shardKeys,"d!");
doQuery("e!doc4", "q","*:*", shardKeys,"e!");
doQuery("f1!f2!doc5,d!doc3", "q","*:*", shardKeys,"f1/8!");
doQuery("f1!f2!doc5,d!doc3,f1!f2!doc5/5", "q","*:*", shardKeys,"f1/8!");
// try using shards parameter
doQuery("b!doc1", "q","*:*", "shards",bucket1);
doQuery("c!doc2", "q","*:*", "shards",bucket2);
doQuery("d!doc3,f1!f2!doc5", "q","*:*", "shards",bucket3);
doQuery("d!doc3,f1!f2!doc5,f1!f2!doc5/5", "q","*:*", "shards",bucket3);
doQuery("e!doc4", "q","*:*", "shards",bucket4);
@ -181,16 +184,16 @@ public class ShardRoutingTest extends AbstractFullDistribZkTestBase {
doQuery("b!doc1,c!doc2", "q","*:*", shardKeys,"b,c"); // query shards that would contain *documents* "b" and "c" (i.e. not prefixes). The upper bits are the same, so the shards should be the same.
doQuery("b!doc1,c!doc2", "q","*:*", shardKeys,"b/1!"); // top bit of hash(b)==1, so shard1 and shard2
doQuery("d!doc3,e!doc4,f1!f2!doc5", "q","*:*", shardKeys,"d/1!"); // top bit of hash(b)==0, so shard3 and shard4
doQuery("d!doc3,e!doc4,f1!f2!doc5,f1!f2!doc5/5", "q","*:*", shardKeys,"d/1!"); // top bit of hash(b)==0, so shard3 and shard4
doQuery("b!doc1,c!doc2", "q","*:*", shardKeys,"b!,c!");
doQuery("b!doc1,f1!f2!doc5,c!doc2,d!doc3,e!doc4", "q","*:*", shardKeys,"foo/0!");
doQuery("b!doc1,f1!f2!doc5,c!doc2,d!doc3,e!doc4,f1!f2!doc5/5", "q","*:*", shardKeys,"foo/0!");
// test targeting deleteByQuery at only certain shards
doDBQ("*:*", shardKeys,"b!");
commit();
doQuery("c!doc2,d!doc3,e!doc4,f1!f2!doc5", "q","*:*");
doQuery("c!doc2,d!doc3,e!doc4,f1!f2!doc5,f1!f2!doc5/5", "q","*:*");
doAddDoc("b!doc1");
doDBQ("*:*", shardKeys,"f1!");

View File

@ -143,7 +143,6 @@ public class TriLevelCompositeIdRoutingTest extends ShardRoutingTest {
Set<String> doQueryGetUniqueIdKeys(String... queryParams) throws Exception {
QueryResponse rsp = cloudClient.query(params(queryParams));
Set<String> obtainedIdKeys = new HashSet<String>();
Set<String> obtainedIdKeys2 = new HashSet<String>();
for (SolrDocument doc : rsp.getResults()) {
obtainedIdKeys.add(getKey((String) doc.get("id")));
}

View File

@ -202,15 +202,16 @@ public class CompositeIdRouter extends HashBasedRouter {
} else {
numBits[0] = 16;
triLevel = false;
}
for (int i = 0; i < parts.length; i++) {
int commaIdx = parts[i].indexOf(bitsSeparator);
if (i < pieces - 1) {
int commaIdx = parts[i].indexOf(bitsSeparator);
if (commaIdx > 0) {
numBits[i] = getNumBits(parts[i], commaIdx);
parts[i] = parts[i].substring(0, commaIdx);
if (commaIdx > 0) {
numBits[i] = getNumBits(parts[i], commaIdx);
parts[i] = parts[i].substring(0, commaIdx);
}
}
hashes[i] = Hash.murmurhash3_x86_32(parts[i], 0, parts[i].length(), 0);
}