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

cast exception while searching with sort function and result grouping

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Patch Available
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.7, 4.8
    • Fix Version/s: None
    • Component/s: search
    • Labels:
      None

      Description

      After upgrading from 4.5.1 to 4.7+, a schema including a "*" dynamic field as text gets a cast exception when using a sort function and result grouping.

      Repro (with example config):

      1. Add "*" dynamic field as a TextField, eg:
        <dynamicField name="*" type="text_general" multiValued="true" />
        
      2. Create sharded collection
        curl 'http://localhost:8983/solr/admin/collections?action=CREATE&name=test&numShards=2&maxShardsPerNode=2'
        
      3. Add example docs (query must have some results)
      4. Submit query which sorts on a function result and uses result grouping:
        {
          "responseHeader": {
            "status": 500,
            "QTime": 50,
            "params": {
              "sort": "sqrt(popularity) desc",
              "indent": "true",
              "q": "*:*",
              "_": "1403709010008",
              "group.field": "manu",
              "group": "true",
              "wt": "json"
            }
          },
          "error": {
            "msg": "java.lang.Double cannot be cast to org.apache.lucene.util.BytesRef",
            "code": 500
          }
        }
        

      Source exception from log:

      ERROR - 2014-06-25 08:10:10.055; org.apache.solr.common.SolrException; java.lang.ClassCastException: java.lang.Double cannot be cast to org.apache.lucene.util.BytesRef
          at org.apache.solr.schema.FieldType.marshalStringSortValue(FieldType.java:981)
          at org.apache.solr.schema.TextField.marshalSortValue(TextField.java:176)
          at org.apache.solr.search.grouping.distributed.shardresultserializer.SearchGroupsResultTransformer.serializeSearchGroup(SearchGroupsResultTransformer.java:125)
          at org.apache.solr.search.grouping.distributed.shardresultserializer.SearchGroupsResultTransformer.transform(SearchGroupsResultTransformer.java:65)
          at org.apache.solr.search.grouping.distributed.shardresultserializer.SearchGroupsResultTransformer.transform(SearchGroupsResultTransformer.java:43)
          at org.apache.solr.search.grouping.CommandHandler.processResult(CommandHandler.java:193)
          at org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:340)
          at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:218)
          at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
        ...
      

      It looks like serializeSearchGroup is matching the sort expression as the "*" dynamic field, which is a TextField in the repro.

        Attachments

        1. SOLR-6203.patch
          36 kB
          Christine Poerschke
        2. SOLR-6203.patch
          63 kB
          Judith Silverman
        3. SOLR-6203.patch
          13 kB
          Judith Silverman
        4. SOLR-6203.patch
          48 kB
          Judith Silverman
        5. SOLR-6203.patch
          8 kB
          Judith Silverman
        6. SOLR-6203.patch
          36 kB
          Judith Silverman
        7. SOLR-6203.patch
          16 kB
          Judith Silverman
        8. SOLR-6203.patch
          21 kB
          Judith Silverman
        9. SOLR-6203-unittest.patch
          1 kB
          Christine Poerschke
        10. SOLR-6203.patch
          117 kB
          Judith Silverman
        11. README
          4 kB
          Judith Silverman
        12. SOLR-6203-unittest.patch
          1 kB
          Nate Dire

          Issue Links

            Activity

              People

              • Assignee:
                cpoerschke Christine Poerschke
                Reporter:
                nated Nate Dire
              • Votes:
                1 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated: