Hi guys,
I have a Solr 4.10.4 instance with a RequestHandler that has a re-ranking query configured like this:

<lst name="defaults">
            <str name="defType">dismax</str>
            ...
            <str name="rqq">{!boost b=someFunction() v=$q}</str>
<str name="rq">{!rerank reRankQuery=$rqq reRankDocs=60 reRankWeight=1.2}</str>
            <str name="sort">score desc</str>
</lst>

Everything is working until the client sends a sort params that doesn't include the score field. So if for example the request contains "sort=price asc" then a NullPointerException is thrown:
/
//09:46:08,548 ERROR [org.apache.solr.core.SolrCore] java.lang.NullPointerException// //[INFO] [talledLocalContainer] at org.apache.lucene.search.TopFieldCollector$OneComparatorScoringMaxScoreCollector.collect(TopFieldCollector.java:291)// //[INFO] [talledLocalContainer] at org.apache.solr.search.ReRankQParserPlugin$ReRankCollector.collect(ReRankQParserPlugin.java:263)// //[INFO] [talledLocalContainer] at org.apache.solr.search.SolrIndexSearcher.sortDocSet(SolrIndexSearcher.java:1999)// //[INFO] [talledLocalContainer] at org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1423)// //[INFO] [talledLocalContainer] at org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:514)// //[INFO] [talledLocalContainer] at org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:484)// //[INFO] [talledLocalContainer] at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:218)// //[INFO] [talledLocalContainer] at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)

/The only way to avoid this exception is to _explicitly_ add th/e "score desc" /value to the incoming field (i.e. sort=price asc, score desc). In this way I get no exception. I said "explicitly" because adding an "appends" section in my handler

<lst name="appends">
    <str name="sort">score desc</str>
</lst>

Even I don't know if that could solve my problem, in practice it is completely ignoring (i.e. I'm still getting the NPE above). However, when I explicitly add "sort=price asc, score desc", as consequence of the re-ranking, the top 60 results, although I said to Solr "order by price", are still shuffled and that's not what I want.

On top of that I have two questions:

 * Any idea about the exception above?
 * How can I disable the re-ranking query in case the order is not by
   score?

About the second question, I'm thinking to the following solutions, but I'm not sure if there's a better way to do that.

1. Create another request handler, which is basically a clone of the handler above but without the re-ranking stuff
2. Use local params for the reRankDocs...

<lst name="defaults">
            <str name="defType">dismax</str>
            ...
            <str name="rqq">{!boost b=someFunction() v=$q}</str>
<str name="rq">{!rerank reRankQuery=$rqq reRankDocs=*$rrd* reRankWeight=1.2}</str>
*<str name="rrd">60</str>*
            <str name="sort">score desc</str>
</lst>

...and have (in case of sorting by something different from the score) the client sending an additional params "rdd=0". This is working but I still need to explicitly declare "sort=price asc, score desc"

Any thoughts?

Best,
Andrea

Reply via email to