Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-12657

Facet streaming expression doesn't support min / max correctly for date fields.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 7.4
    • Fix Version/s: 7.4.1
    • Component/s: streaming expressions
    • Labels:
      None

      Description

      Using this streaming expression to compute a min / max timestamp for each movie_id in my ratings collection (movielens),

      
      facet(ratings,
       q="movie_id:[* TO *]",
       buckets="movie_id",
       bucketSizeLimit=1254,
       bucketSorts="movie_id asc", count(*),
       min(rating_timestamp),
       max(rating_timestamp)
      )
      
      

      I get the following errors:

      
      2018-08-10T17:48:58,293 - INFO [qtp726950788-385:solr.core.SolrCore@2544] - \{collection=c:ratings, core=x:ratings_shard1_replica_n1, node_name=n:192.168.1.6:8983_solr, replica=r:core_node2, shard=s:shard1} - [ratings_shard1_replica_n1] webapp=/solr path=/stream params=\{expr=facet(ratings,%0a++++++++++++++q%3D"movie_id:[*+TO+*]",%0a++++++++++++++buckets%3D"movie_id",%0a++++++++++++++bucketSizeLimit%3D1254,%0a++++++++++++++bucketSorts%3D"movie_id+asc",+count(*),%0a++++++++++++++min(rating_timestamp),%0a++++++++++++++max(rating_timestamp)%0a)&_=1533923249300} status=0 QTime=0
      2018-08-10T17:48:58,313 - INFO [qtp726950788-17:solr.core.SolrCore@2544] - \{collection=c:ratings, core=x:ratings_shard1_replica_n1, node_name=n:192.168.1.6:8983_solr, replica=r:core_node2, shard=s:shard1} - [ratings_shard1_replica_n1] webapp=/solr path=/select params=\{q=movie_id:[*+TO+*]&json.facet={"movie_id":{"type":"terms","field":"movie_id","limit":1254,"sort":{"index":"asc"},"facet":\{"facet_0":"min(rating_timestamp)","facet_1":"max(rating_timestamp)"}}}&_stateVer_=ratings:4&bucketSizeLimit=1254&rows=0&wt=javabin&version=2} hits=100000 status=0 QTime=17
      2018-08-10T17:48:58,316 - ERROR [qtp726950788-385:solr.common.SolrException@148] - \{collection=c:ratings, core=x:ratings_shard1_replica_n1, node_name=n:192.168.1.6:8983_solr, replica=r:core_node2, shard=s:shard1} - java.io.IOException: java.lang.ClassCastException: java.util.Date cannot be cast to java.lang.Number
       at org.apache.solr.client.solrj.io.stream.FacetStream.open(FacetStream.java:346)
       at org.apache.solr.client.solrj.io.stream.ExceptionStream.open(ExceptionStream.java:54)
       at org.apache.solr.handler.StreamHandler$TimerStream.open(StreamHandler.java:397)
       at org.apache.solr.client.solrj.io.stream.TupleStream.writeMap(TupleStream.java:83)
       at org.apache.solr.response.JSONWriter.writeMap(JSONResponseWriter.java:539)
       at org.apache.solr.response.TextResponseWriter.writeVal(TextResponseWriter.java:181)
       at org.apache.solr.response.JSONWriter.writeNamedListAsMapWithDups(JSONResponseWriter.java:209)
       at org.apache.solr.response.JSONWriter.writeNamedList(JSONResponseWriter.java:325)
       at org.apache.solr.response.JSONWriter.writeResponse(JSONResponseWriter.java:120)
       at org.apache.solr.response.JSONResponseWriter.write(JSONResponseWriter.java:71)
       at org.apache.solr.response.QueryResponseWriterUtil.writeQueryResponse(QueryResponseWriterUtil.java:65)
       at org.apache.solr.servlet.HttpSolrCall.writeResponse(HttpSolrCall.java:787)
       at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:524)
       at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:377)
       at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:323)
       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:748)
      Caused by: java.lang.ClassCastException: java.util.Date cannot be cast to java.lang.Number
       at org.apache.solr.client.solrj.io.stream.FacetStream.fillTuples(FacetStream.java:502)
       at org.apache.solr.client.solrj.io.stream.FacetStream.getTuples(FacetStream.java:459)
       at org.apache.solr.client.solrj.io.stream.FacetStream.open(FacetStream.java:342)
       ... 38 more
      
      

       

      However, the JSON facet API definitely supports this: 

      
      curl http://localhost:8983/solr/ratings/query -d 'rows=0&q=movie_id:[* TO *]&json.facet={
      
        movie_id:{
      
          type:terms,
      
          field:"movie_id",
      
          limit:100,
      
          sort:\{count:desc},
      
          facet: {
      
            min_ts: "min(rating_timestamp)"
      
            max_ts: "max(rating_timestamp)"
      
          }
      
        }
      
      }'
      
      

      Gives the expected results:

      
      "facets":{
      
          "count":100000,
      
          "movie_id":{
      
            "buckets":[{
      
                "val":"50",
      
                "count":583,
      
                "min_ts":"1997-09-20T04:29:10Z",
      
                "max_ts":"1998-04-22T16:53:14Z"},
      
              {
      
                "val":"258",
      
                "count":509,
      
                "min_ts":"1997-09-20T20:12:17Z",
      
                "max_ts":"1998-04-22T22:09:38Z"},
      
              ...
      
      

        Attachments

          Activity

            People

            • Assignee:
              thelabdude Timothy Potter
              Reporter:
              thelabdude Timothy Potter
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: