SOLR-2110: remove restrictions on local param substitution

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@995264 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2010-09-08 22:04:19 +00:00
parent 8b396e93ed
commit 9dd3bebcfb
3 changed files with 22 additions and 8 deletions

View File

@ -178,15 +178,15 @@ public class QueryParsing {
// saw equals, so read value
p.pos++;
ch = p.peek();
boolean deref = false;
if (ch == '$') {
p.pos++;
ch = p.peek();
deref = true; // dereference whatever value is read by treating it as a variable name
}
if (ch == '\"' || ch == '\'') {
val = p.getQuotedString();
} else if (ch == '$') {
p.pos++;
// dereference parameter
String pname = p.getId();
if (params != null) {
val = params.get(pname);
}
} else {
// read unquoted literal ended by whitespace or '}'
// there is no escaping.
@ -203,6 +203,12 @@ public class QueryParsing {
p.pos++;
}
}
if (deref) { // dereference parameter
if (params != null) {
val = params.get(val);
}
}
}
if (target != null) target.put(id, val);
}

View File

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

View File

@ -210,6 +210,14 @@ public class TestQueryTypes extends AbstractSolrTestCase {
,"//result[@numFound='2']"
);
// test wacky param names
assertQ(
req("q","{!prefix f=$a/b/c v=$'a b/c'}"
,"a/b/c","v_t", "a b/c", "hel"
)
,"//result[@numFound='2']"
);
assertQ("test param subst with literal",
req("q","{!prefix f=$myf v=$my.v}"
,"myf","v_s", "my.v", "{!lit"