Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-8403

EmbeddedSolrServer has broken sorting with functions and non-alphanumeric symbols in field names

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 5.3.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      We are trying to use EmbeddedSolrServer to test our Java code, that sends queries to Solr server.

      We have a number of non-alphanumeric characters in field names in our schema, and such field names work fine for searching and sorting on both real Solr server (via HttpSolrClient) and on EmbeddedSolrServer.

      But when we make search query that has functions in sort clause, real server handles these queries correctly while EmbeddedSolrServer throws exception.

      Suppose, we have a field with name foo:bar. The following query works fine with both real server and EmbeddedSolrServer:

      solrClient.query(new SolrQuery("*:*").addSort("foo:bar", SolrQuery.ORDER.desc));
      

      But when we try to use functions in sort clause, exception is thrown by EmbeddedSolrServer (real server works correctly). For the following code:

      solrClient.query(new SolrQuery("*:*").addSort("def(foo:bar,0)", SolrQuery.ORDER.desc));
      

      we get the following exception:

      org.apache.solr.common.SolrException: sort param could not be parsed as a query, and is not a field that exists in the index: def(foo:bar,0)
      	at org.apache.solr.search.QueryParsing.parseSortSpec(QueryParsing.java:348)
      	at org.apache.solr.search.QParser.getSort(QParser.java:247)
      	at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:185)
      	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:251)
      	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
      	at org.apache.solr.core.SolrCore.execute(SolrCore.java:2068)
      	at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:179)
      	at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:135)
      	at org.apache.solr.client.solrj.SolrClient.query(SolrClient.java:943)
      	at org.apache.solr.client.solrj.SolrClient.query(SolrClient.java:958)
      	...
      

      If we have a space character between function arguments:

      solrClient.query(new SolrQuery("*:*").addSort("def(foo:bar, 0)", SolrQuery.ORDER.desc));
      

      we get different exception:

      org.apache.solr.common.SolrException: Can't determine a Sort Order (asc or desc) in sort spec 'def(foo:bar, 0) desc', pos=12
      	at org.apache.solr.search.QueryParsing.parseSortSpec(QueryParsing.java:329)
      	at org.apache.solr.search.QParser.getSort(QParser.java:247)
      	at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:185)
      	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:251)
      	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
      	at org.apache.solr.core.SolrCore.execute(SolrCore.java:2068)
      	at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:179)
      	at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:135)
      	at org.apache.solr.client.solrj.SolrClient.query(SolrClient.java:943)
      	at org.apache.solr.client.solrj.SolrClient.query(SolrClient.java:958)
      	...
      

      Anyway, we have our tests failing with correctly written code that works on real server. Please, make EmbeddedSolrServer to behave the same way as the real Solr server.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                vasiliy.bout Vasiliy Bout
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: