You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "Kuai, Ben" <Be...@sensis.com.au> on 2012/11/12 04:12:08 UTC

sort by function error

Hi

I am trying to use sort by function something like "sort=sum(field1, field2) asc "

But it is not working and I got error " SortField needs to be rewritten through Sort.rewrite(..) and SortField.rewrite"

Please shed me some light on this.

Thanks
Ben

Full exception stack track:
SEVERE: java.lang.IllegalStateException: SortField needs to be rewritten through Sort.rewrite(..) and SortField.rewrite(..)
    at org.apache.lucene.search.SortField.getComparator(SortField.java:484)
    at org.apache.lucene.search.grouping.AbstractFirstPassGroupingCollector.<init>(AbstractFirstPassGroupingCollector.java:82)
    at org.apache.lucene.search.grouping.TermFirstPassGroupingCollector.<init>(TermFirstPassGroupingCollector.java:58)
    at org.apache.solr.search.Grouping$TermFirstPassGroupingCollectorJava6.<init>(Grouping.java:1009)
    at org.apache.solr.search.Grouping$CommandField.createFirstPassCollector(Grouping.java:632)
    at org.apache.solr.search.Grouping.execute(Grouping.java:301)
    at org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:373)
    at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:201)
    at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
    at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316)
    at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:353)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:248)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)



RE: sort by function error

Posted by "Kuai, Ben" <Be...@sensis.com.au>.
Hi Yonik

I will give the latest 4.0 release a try. 

Thanks anyway.

Cheers
Ben
________________________________________
From: yseeley@gmail.com [yseeley@gmail.com] on behalf of Yonik Seeley [yonik@lucidworks.com]
Sent: Tuesday, November 13, 2012 2:04 PM
To: solr-user@lucene.apache.org
Subject: Re: sort by function error

I can't reproduce this with the example data.  Here's an example of
what I tried:

http://localhost:8983/solr/query?q=*:*&sort=geodist(store,-32.123323,108.123323)+asc&group.field=inStock&group=true

Perhaps this is an issue that's since been fixed.

-Yonik
http://lucidworks.com


On Mon, Nov 12, 2012 at 11:19 PM, Kuai, Ben <Be...@sensis.com.au> wrote:
> Hi Yonik
>
> Thanks for the reply.
> My sample query,
>
> q="cafe"&sort=geodist(geoLocation,-32.123323,108.123323)+asc&group.field=familyId
>
> <field name="geoLocation" type="latLon" indexed="true" stored="false" />
> <field name="familyId" type="string" indexed="true" stored="false" />
>
> as long as I remove the group field the query working.
>
> BTW, I just find out that the version of solr we are using is an old copy of 4.0 snapshot before the alpha release. Could that be the problem?  we have some customized parsers so it will take quite some time to upgrade.
>
>
> Ben
> ________________________________________
> From: yseeley@gmail.com [yseeley@gmail.com] on behalf of Yonik Seeley [yonik@lucidworks.com]
> Sent: Tuesday, November 13, 2012 6:46 AM
> To: solr-user@lucene.apache.org
> Subject: Re: sort by function error
>
> On Mon, Nov 12, 2012 at 5:24 AM, Kuai, Ben <Be...@sensis.com.au> wrote:
>> more information,  problem only happends when I have both sort by function and grouping in query.
>
> I haven't been able to duplicate this with a few ad-hoc queries.
> Could you give your complete request (or at least all of the relevant
> grouping and sorting parameters), as well as the field type you are
> grouping on?
>
> -Yonik
> http://lucidworks.com

Re: sort by function error

Posted by Yonik Seeley <yo...@lucidworks.com>.
I can't reproduce this with the example data.  Here's an example of
what I tried:

http://localhost:8983/solr/query?q=*:*&sort=geodist(store,-32.123323,108.123323)+asc&group.field=inStock&group=true

Perhaps this is an issue that's since been fixed.

-Yonik
http://lucidworks.com


On Mon, Nov 12, 2012 at 11:19 PM, Kuai, Ben <Be...@sensis.com.au> wrote:
> Hi Yonik
>
> Thanks for the reply.
> My sample query,
>
> q="cafe"&sort=geodist(geoLocation,-32.123323,108.123323)+asc&group.field=familyId
>
> <field name="geoLocation" type="latLon" indexed="true" stored="false" />
> <field name="familyId" type="string" indexed="true" stored="false" />
>
> as long as I remove the group field the query working.
>
> BTW, I just find out that the version of solr we are using is an old copy of 4.0 snapshot before the alpha release. Could that be the problem?  we have some customized parsers so it will take quite some time to upgrade.
>
>
> Ben
> ________________________________________
> From: yseeley@gmail.com [yseeley@gmail.com] on behalf of Yonik Seeley [yonik@lucidworks.com]
> Sent: Tuesday, November 13, 2012 6:46 AM
> To: solr-user@lucene.apache.org
> Subject: Re: sort by function error
>
> On Mon, Nov 12, 2012 at 5:24 AM, Kuai, Ben <Be...@sensis.com.au> wrote:
>> more information,  problem only happends when I have both sort by function and grouping in query.
>
> I haven't been able to duplicate this with a few ad-hoc queries.
> Could you give your complete request (or at least all of the relevant
> grouping and sorting parameters), as well as the field type you are
> grouping on?
>
> -Yonik
> http://lucidworks.com

RE: sort by function error

Posted by "Kuai, Ben" <Be...@sensis.com.au>.
Hi Yonik

Thanks for the reply.
My sample query,

q="cafe"&sort=geodist(geoLocation,-32.123323,108.123323)+asc&group.field=familyId

<field name="geoLocation" type="latLon" indexed="true" stored="false" />
<field name="familyId" type="string" indexed="true" stored="false" />

as long as I remove the group field the query working.

BTW, I just find out that the version of solr we are using is an old copy of 4.0 snapshot before the alpha release. Could that be the problem?  we have some customized parsers so it will take quite some time to upgrade. 


Ben
________________________________________
From: yseeley@gmail.com [yseeley@gmail.com] on behalf of Yonik Seeley [yonik@lucidworks.com]
Sent: Tuesday, November 13, 2012 6:46 AM
To: solr-user@lucene.apache.org
Subject: Re: sort by function error

On Mon, Nov 12, 2012 at 5:24 AM, Kuai, Ben <Be...@sensis.com.au> wrote:
> more information,  problem only happends when I have both sort by function and grouping in query.

I haven't been able to duplicate this with a few ad-hoc queries.
Could you give your complete request (or at least all of the relevant
grouping and sorting parameters), as well as the field type you are
grouping on?

-Yonik
http://lucidworks.com

Re: sort by function error

Posted by Yonik Seeley <yo...@lucidworks.com>.
On Mon, Nov 12, 2012 at 5:24 AM, Kuai, Ben <Be...@sensis.com.au> wrote:
> more information,  problem only happends when I have both sort by function and grouping in query.

I haven't been able to duplicate this with a few ad-hoc queries.
Could you give your complete request (or at least all of the relevant
grouping and sorting parameters), as well as the field type you are
grouping on?

-Yonik
http://lucidworks.com

RE: sort by function error

Posted by "Kuai, Ben" <Be...@sensis.com.au>.
more information,  problem only happends when I have both sort by function and grouping in query.


________________________________________
From: Kuai, Ben [Ben.Kuai@sensis.com.au]
Sent: Monday, November 12, 2012 2:12 PM
To: solr-user@lucene.apache.org
Subject: sort by function error

Hi

I am trying to use sort by function something like "sort=sum(field1, field2) asc "

But it is not working and I got error " SortField needs to be rewritten through Sort.rewrite(..) and SortField.rewrite"

Please shed me some light on this.

Thanks
Ben

Full exception stack track:
SEVERE: java.lang.IllegalStateException: SortField needs to be rewritten through Sort.rewrite(..) and SortField.rewrite(..)
    at org.apache.lucene.search.SortField.getComparator(SortField.java:484)
    at org.apache.lucene.search.grouping.AbstractFirstPassGroupingCollector.<init>(AbstractFirstPassGroupingCollector.java:82)
    at org.apache.lucene.search.grouping.TermFirstPassGroupingCollector.<init>(TermFirstPassGroupingCollector.java:58)
    at org.apache.solr.search.Grouping$TermFirstPassGroupingCollectorJava6.<init>(Grouping.java:1009)
    at org.apache.solr.search.Grouping$CommandField.createFirstPassCollector(Grouping.java:632)
    at org.apache.solr.search.Grouping.execute(Grouping.java:301)
    at org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:373)
    at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:201)
    at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
    at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316)
    at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:353)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:248)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)