SOLR-2110: make sure to quote keys that start with $

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@995557 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2010-09-09 19:39:37 +00:00
parent 8f8132bdfc
commit c6acdba4a2
2 changed files with 8 additions and 5 deletions

View File

@ -216,11 +216,13 @@ public class QueryParsing {
public static String encodeLocalParamVal(String val) { public static String encodeLocalParamVal(String val) {
int len = val.length(); int len = val.length();
int i; int i = 0;
for (i=0; i<len; i++) { if (len > 0 && val.charAt(0) != '$') {
for (;i<len; i++) {
char ch = val.charAt(i); char ch = val.charAt(i);
if (Character.isWhitespace(ch) || ch=='}') break; if (Character.isWhitespace(ch) || ch=='}') break;
} }
}
if (i>=len) return val; if (i>=len) return val;

View File

@ -177,7 +177,8 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
handle.put("facet_fields", SKIPVAL); handle.put("facet_fields", SKIPVAL);
query("q","*:*", "rows",0, "facet","true", "facet.field",t1,"facet.limit",5, "facet.shard.limit",5); query("q","*:*", "rows",0, "facet","true", "facet.field",t1,"facet.limit",5, "facet.shard.limit",5);
// check a complex key name // check a complex key name
query("q","*:*", "rows",0, "facet","true", "facet.field","{!key='a b/c \\' \\} foo'}"+t1,"facet.limit",5, "facet.shard.limit",5); query("q","*:*", "rows",0, "facet","true", "facet.field","{!key='$a b/c \\' \\} foo'}"+t1,"facet.limit",5, "facet.shard.limit",5);
query("q","*:*", "rows",0, "facet","true", "facet.field","{!key='$a'}"+t1,"facet.limit",5, "facet.shard.limit",5);
handle.remove("facet_fields"); handle.remove("facet_fields");