My guess is that it's this: multiValued="true" Most sorting doesn't work on mutivalued fields as it's ambiguous what sorting means; which value should be used? This isn't a very helpful stack trace if that's the issue though I'll admit. There are some JIRAs out there to allow sorting on, say, the min or max value here but they're not in place yet..
May be totally wrong, but that's the first thing I'd look at. Come to think I'm not entirely sure a dateRangeField is sortable for that matter, haven't tried it personally. BTW, I'd also define docValues for a field if I intended to sort on it. Best, Erick On Mon, Nov 7, 2016 at 4:13 AM, Georgios Petasis <petas...@yahoo.gr.invalid> wrote: > Dear all, > > I have defined a field "date_range" as: > <fieldType name="date_range" class="solr.DateRangeField" multiValued="true" > indexed="true"/> > > The field works (and I can perform range queries for these dates). but I > have not found a way to sort > results based on this field. I have tried with the dist(), ms() functions, > to use the boost plugin, etc. and everything fails. > Either with an error message, like: > > fl=startDate&q={!boost+b=$dateboost+v=$qq}&dateboost=recip(ms(NOW,startDate),3.16e-11,1,1)&qq=* > A ValueSource isn't directly available from this field. Instead try a query > using the distance as the score. > > or a stack trace: > fl=startDate&q=*&sort="ms(startDate)"+asc" > java.lang.UnsupportedOperationException > at > org.apache.lucene.queries.function.FunctionValues.doubleVal(FunctionValues.java:47) > at > org.apache.lucene.queries.function.ValueSource$ValueSourceComparator.copy(ValueSource.java:153) > at > org.apache.lucene.search.TopFieldCollector$SimpleFieldCollector$1.collect(TopFieldCollector.java:206) > at > org.apache.lucene.search.Weight$DefaultBulkScorer.scoreAll(Weight.java:221) > at > org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:172) > at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39) > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:669) > at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:473) > at > org.apache.solr.search.SolrIndexSearcher.buildAndRunCollectorChain(SolrIndexSearcher.java:211) > at > org.apache.solr.search.SolrIndexSearcher.getDocListNC(SolrIndexSearcher.java:1765) > at > org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1582) > at > org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:581) > at > org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:528) > at > org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:295) > at > org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:154) > at org.apache.solr.core.SolrCore.execute(SolrCore.java:2089) > at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:652) > at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:459) > at > org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:257) > at > org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:208) > at > org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668) > at > org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581) > at > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) > at > org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) > at > org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) > at > org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1160) > at > org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511) > at > org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) > at > org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1092) > at > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) > at > org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) > at > org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:119) > at > org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) > at org.eclipse.jetty.server.Server.handle(Server.java:518) > at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308) > at > org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:244) > at > org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273) > at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) > at > org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93) > at > org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:246) > at > org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:156) > at > org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654) > at > org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572) > at java.lang.Thread.run(Thread.java:745) > > > I am using Solr 6.2.1. > > Regards, > George