Hmm this is in fact a regression.

TopFieldCollector expects (but does not verify) that numHits is > 0.

I guess to fix this we could fix TopFieldCollector.create to return a
NullCollector when numHits is 0.

But: why is your app doing this?  Ie, if numHits (rows) is 0, the only
useful thing you can get is totalHits?

Still I think we should fix it in Lucene -- it's a nuisance to push
such corner case checks up into the apps.  I'll open an issue...

Mike

On Mon, Nov 29, 2010 at 7:14 AM, Martin Grotzke
<martin.grot...@googlemail.com> wrote:
> Hi,
>
> after an upgrade from solr-1.3 to 1.4.1 we're getting an
> ArrayIndexOutOfBoundsException for a query with rows=0 and a sort
> param specified:
>
> java.lang.ArrayIndexOutOfBoundsException: 0
>        at 
> org.apache.lucene.search.FieldComparator$StringOrdValComparator.copy(FieldComparator.java:660)
>        at 
> org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.collect(TopFieldCollector.java:84)
>        at 
> org.apache.solr.search.SolrIndexSearcher.sortDocSet(SolrIndexSearcher.java:1391)
>        at 
> org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:872)
>        at 
> org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:341)
>        at 
> org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:182)
>        at 
> org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:195)
>        at 
> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131)
>        at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316)
>
> The query is e.g.:
> /select/?sort=popularity+desc&rows=0&start=0&q=foo
>
> When this is changed to rows=1 or when the sort param is removed the
> exception is gone and everything's fine.
>
> With a clean 1.4.1 installation (unzipped, started example and posted
> two documents as described in the tutorial) this issue is not
> reproducable.
>
> Does anyone have a clue what might be the reason for this and how we
> could fix this on the solr side?
> Of course - for a quick fix - I'll change our app so that there's no
> sort param specified when rows=0.
>
> Thanx && cheers,
> Martin
>
> --
> Martin Grotzke
> http://twitter.com/martin_grotzke
>

Reply via email to