Solr
  1. Solr
  2. SOLR-3522

"literal" function can not be parsed

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0-ALPHA, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      attempting to use the "literal" function in the fl param causes a parse error...

      Example queries with functions that works fine...

      http://localhost:8983/solr/collection1/select?q=*:*&fl=foo:sum%284,5%29
      http://localhost:8983/solr/collection1/select?fl=score&q={!func}strdist%28%22foo%22,%22fo%22,edit%29
      

      Examples using literal function that fails...

      http://localhost:8983/solr/collection1/select?q=*:*&fl=foo:literal%28%22foo%22%29
      http://localhost:8983/solr/collection1/select?fl=score&q={!func}strdist%28%22foo%22,literal%28%22fo%22%29,edit%29
      

        Activity

        Hide
        Hoss Man added a comment -

        revised summary and description .. seems to be a general problem parsing the "literal" function, not specific to "fl"

        Show
        Hoss Man added a comment - revised summary and description .. seems to be a general problem parsing the "literal" function, not specific to "fl"
        Hide
        Hoss Man added a comment -

        Full Stacks...

        Jun 7, 2012 4:32:32 PM org.apache.solr.common.SolrException log
        SEVERE: org.apache.solr.common.SolrException: Error parsing fieldname: Expected ')' at position 8 in 'literal("foo")'
        	at org.apache.solr.search.ReturnFields.add(ReturnFields.java:353)
        	at org.apache.solr.search.ReturnFields.parseFieldList(ReturnFields.java:115)
        	at org.apache.solr.search.ReturnFields.<init>(ReturnFields.java:101)
        	at org.apache.solr.search.ReturnFields.<init>(ReturnFields.java:77)
        	at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:97)
        	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:183)
        	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
        	at org.apache.solr.core.SolrCore.execute(SolrCore.java:1555)
        	at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:442)
        	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:263)
        	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1337)
        	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:484)
        	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
        	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
        	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
        	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
        	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
        	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
        	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
        	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
        	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
        	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
        	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
        	at org.eclipse.jetty.server.Server.handle(Server.java:351)
        	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
        	at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)
        	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
        	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
        	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
        	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
        	at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)
        	at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)
        	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
        	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
        	at java.lang.Thread.run(Thread.java:662)
        Caused by: org.apache.lucene.queryparser.classic.ParseException: Expected ')' at position 8 in 'literal("foo")'
        	at org.apache.solr.search.QueryParsing$StrParser.expect(QueryParsing.java:629)
        	at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:367)
        	at org.apache.solr.search.FunctionQParser.parse(FunctionQParser.java:70)
        	at org.apache.solr.search.QParser.getQuery(QParser.java:145)
        	at org.apache.solr.search.ReturnFields.add(ReturnFields.java:289)
        	... 34 more
        
        
        Jun 7, 2012 4:32:54 PM org.apache.solr.common.SolrException log
        SEVERE: org.apache.solr.common.SolrException: org.apache.lucene.queryparser.classic.ParseException: Expected ')' at position 22 in 'strdist("foo",literal("fo"),edit)'
        	at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:148)
        	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:183)
        	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
        	at org.apache.solr.core.SolrCore.execute(SolrCore.java:1555)
        	at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:442)
        	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:263)
        	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1337)
        	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:484)
        	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
        	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
        	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
        	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
        	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
        	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
        	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
        	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
        	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
        	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
        	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
        	at org.eclipse.jetty.server.Server.handle(Server.java:351)
        	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
        	at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)
        	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
        	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
        	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
        	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
        	at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)
        	at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)
        	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
        	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
        	at java.lang.Thread.run(Thread.java:662)
        Caused by: org.apache.lucene.queryparser.classic.ParseException: Expected ')' at position 22 in 'strdist("foo",literal("fo"),edit)'
        	at org.apache.solr.search.QueryParsing$StrParser.expect(QueryParsing.java:629)
        	at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:367)
        	at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:234)
        	at org.apache.solr.search.ValueSourceParser$22.parse(ValueSourceParser.java:332)
        	at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:366)
        	at org.apache.solr.search.FunctionQParser.parse(FunctionQParser.java:70)
        	at org.apache.solr.search.QParser.getQuery(QParser.java:145)
        	at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:118)
        	... 30 more
        
        
        Show
        Hoss Man added a comment - Full Stacks... Jun 7, 2012 4:32:32 PM org.apache.solr.common.SolrException log SEVERE: org.apache.solr.common.SolrException: Error parsing fieldname: Expected ')' at position 8 in 'literal("foo")' at org.apache.solr.search.ReturnFields.add(ReturnFields.java:353) at org.apache.solr.search.ReturnFields.parseFieldList(ReturnFields.java:115) at org.apache.solr.search.ReturnFields.<init>(ReturnFields.java:101) at org.apache.solr.search.ReturnFields.<init>(ReturnFields.java:77) at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:97) at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:183) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129) at org.apache.solr.core.SolrCore.execute(SolrCore.java:1555) at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:442) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:263) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1337) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:484) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) at org.eclipse.jetty.server.Server.handle(Server.java:351) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454) at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66) at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534) at java.lang.Thread.run(Thread.java:662) Caused by: org.apache.lucene.queryparser.classic.ParseException: Expected ')' at position 8 in 'literal("foo")' at org.apache.solr.search.QueryParsing$StrParser.expect(QueryParsing.java:629) at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:367) at org.apache.solr.search.FunctionQParser.parse(FunctionQParser.java:70) at org.apache.solr.search.QParser.getQuery(QParser.java:145) at org.apache.solr.search.ReturnFields.add(ReturnFields.java:289) ... 34 more Jun 7, 2012 4:32:54 PM org.apache.solr.common.SolrException log SEVERE: org.apache.solr.common.SolrException: org.apache.lucene.queryparser.classic.ParseException: Expected ')' at position 22 in 'strdist("foo",literal("fo"),edit)' at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:148) at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:183) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129) at org.apache.solr.core.SolrCore.execute(SolrCore.java:1555) at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:442) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:263) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1337) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:484) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) at org.eclipse.jetty.server.Server.handle(Server.java:351) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454) at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66) at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534) at java.lang.Thread.run(Thread.java:662) Caused by: org.apache.lucene.queryparser.classic.ParseException: Expected ')' at position 22 in 'strdist("foo",literal("fo"),edit)' at org.apache.solr.search.QueryParsing$StrParser.expect(QueryParsing.java:629) at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:367) at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:234) at org.apache.solr.search.ValueSourceParser$22.parse(ValueSourceParser.java:332) at org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:366) at org.apache.solr.search.FunctionQParser.parse(FunctionQParser.java:70) at org.apache.solr.search.QParser.getQuery(QParser.java:145) at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:118) ... 30 more
        Hide
        Hoss Man added a comment -

        Looking into this, it seems that the literal function is completley broken in 3.6 as well – raw literals work, just not the literal("foo") or literal($foo}).

        problem seems to be a simple mistake of calling "fp.getString()" (which is the entire input string) instead of using fp.parseArg() ... i'll work on a test & fix.

        Show
        Hoss Man added a comment - Looking into this, it seems that the literal function is completley broken in 3.6 as well – raw literals work, just not the literal("foo") or literal($foo}) . problem seems to be a simple mistake of calling "fp.getString()" (which is the entire input string) instead of using fp.parseArg() ... i'll work on a test & fix.
        Hide
        Hoss Man added a comment -

        patch that should fix the problem ... except that the test still fails in a way that suggests StringDistanceFunction isn't implementing equals properly (two FunctionQueries parsed from identical input aren't asserting equally) so now i need to go down that rabbit hole. (i may just have astupid mistake in the test i'm not seeing at the moment)

        Show
        Hoss Man added a comment - patch that should fix the problem ... except that the test still fails in a way that suggests StringDistanceFunction isn't implementing equals properly (two FunctionQueries parsed from identical input aren't asserting equally) so now i need to go down that rabbit hole. (i may just have astupid mistake in the test i'm not seeing at the moment)
        Hide
        Hoss Man added a comment -

        Committed revision 1351460. - trunk
        Committed revision 1351462. - 4x

        deferring the more complicated (and broken) query equalities test to SOLR-3548

        Show
        Hoss Man added a comment - Committed revision 1351460. - trunk Committed revision 1351462. - 4x deferring the more complicated (and broken) query equalities test to SOLR-3548

          People

          • Assignee:
            Hoss Man
            Reporter:
            Hoss Man
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development