You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Vasiliy Bout (JIRA)" <ji...@apache.org> on 2015/12/11 12:06:10 UTC

[jira] [Created] (SOLR-8403) EmbeddedSolrServer has broken sorting with functions and non-alphanumeric symbols in field names

Vasiliy Bout created SOLR-8403:
----------------------------------

             Summary: EmbeddedSolrServer has broken sorting with functions and non-alphanumeric symbols in field names
                 Key: SOLR-8403
                 URL: https://issues.apache.org/jira/browse/SOLR-8403
             Project: Solr
          Issue Type: Bug
    Affects Versions: 5.3.1
            Reporter: Vasiliy Bout


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:
{code}
solrClient.query(new SolrQuery("*:*").addSort("foo:bar", SolrQuery.ORDER.desc));
{code}

But when we try to use functions in sort clause, exception is thrown by EmbeddedSolrServer (real server works correctly). For the following code:
{code}
solrClient.query(new SolrQuery("*:*").addSort("def(foo:bar,0)", SolrQuery.ORDER.desc));
{code}
we get the following exception:
{noformat}
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)
	...
{noformat}

If we have a space character between function arguments:
{code}
solrClient.query(new SolrQuery("*:*").addSort("def(foo:bar, 0)", SolrQuery.ORDER.desc));
{code}
we get different exception:
{noformat}
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)
	...
{noformat}

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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org