diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 1053dd8c4e3..f605a9272f2 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -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 ---------------------- diff --git a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java index a8acb77b60b..75ade0dcd3f 100755 --- a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java +++ b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java @@ -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() { diff --git a/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java b/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java index 2885b29633c..6e13ce2dc0b 100644 --- a/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java +++ b/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java @@ -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()); + } }