SOLR-3522: fixed parsing of the 'literal()' function

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1351460 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2012-06-18 19:03:21 +00:00
parent 7d0d55b0bf
commit f6bd05ca2f
3 changed files with 25 additions and 1 deletions

View File

@ -509,6 +509,8 @@ Bug Fixes
* SOLR-3541: add missing solrj dependencies to binary packages.
(Thijs Vonk via siren)
* SOLR-3522: fixed parsing of the 'literal()' function (hossman)
Other Changes
----------------------

View File

@ -104,7 +104,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
addParser("literal", new ValueSourceParser() {
@Override
public ValueSource parse(FunctionQParser fp) throws ParseException {
return new LiteralValueSource(fp.getString());
return new LiteralValueSource(fp.parseArg());
}
});
addParser("rord", new ValueSourceParser() {

View File

@ -231,4 +231,26 @@ public class QueryParsingTest extends SolrTestCaseJ4 {
req.close();
}
public void testLiteralFunction() throws Exception {
final String NAME = FunctionQParserPlugin.NAME;
SolrQueryRequest req = req("variable", "foobar");
assertNotNull(QParser.getParser
("literal('a value')",
NAME, req).getQuery());
assertNotNull(QParser.getParser
("literal('a value')",
NAME, req).getQuery());
assertNotNull(QParser.getParser
("literal(\"a value\")",
NAME, req).getQuery());
assertNotNull(QParser.getParser
("literal($variable)",
NAME, req).getQuery());
assertNotNull(QParser.getParser
("strdist(\"a value\",literal('a value'),edit)",
NAME, req).getQuery());
}
}