Solr
  1. Solr
  2. SOLR-6118

expand.sort doesn't work with function queries

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.8
    • Fix Version/s: 4.9, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      The new ExpandComponent doesn't support function queries in the expand.sort parameter, such as geodist() for example. Here's the stack trace if you try:

      527561 [qtp1458849419-16] ERROR org.apache.solr.servlet.SolrDispatchFilter  – null:java.lang.IllegalStateException: SortField needs to be rewritten through Sort.rewrite(..) and SortField.rewrite(..)
      	at org.apache.lucene.search.SortField.getComparator(SortField.java:433)
      	at org.apache.lucene.search.FieldValueHitQueue$OneComparatorFieldValueHitQueue.<init>(FieldValueHitQueue.java:66)
      	at org.apache.lucene.search.FieldValueHitQueue.create(FieldValueHitQueue.java:171)
      	at org.apache.lucene.search.TopFieldCollector.create(TopFieldCollector.java:1133)
      	at org.apache.lucene.search.TopFieldCollector.create(TopFieldCollector.java:1079)
      	at org.apache.solr.handler.component.ExpandComponent$GroupExpandCollector.<init>(ExpandComponent.java:310)
      	at org.apache.solr.handler.component.ExpandComponent.process(ExpandComponent.java:203)
      	at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:218)
      	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
      	at org.apache.solr.core.SolrCore.execute(SolrCore.java:1952)
      
      

        Activity

        Hide
        David Smiley added a comment -

        Simple fix w/ test. I think I've been bitten by this type of bug before – forgetting to call:

          if (sort != null)
            sort = sort.rewrite(searcher);
        

        It'd be nice if somehow Lucene's Sort.java maintained a "rewritten" boolean flag so that a bug like this would have been caught earlier during development. Maybe that's the solution, maybe not.

        I noticed some indentation/spacing problems in ExpandComponent.java. I'll fix them in a separate commit.

        Show
        David Smiley added a comment - Simple fix w/ test. I think I've been bitten by this type of bug before – forgetting to call: if (sort != null ) sort = sort.rewrite(searcher); It'd be nice if somehow Lucene's Sort.java maintained a "rewritten" boolean flag so that a bug like this would have been caught earlier during development. Maybe that's the solution, maybe not. I noticed some indentation/spacing problems in ExpandComponent.java. I'll fix them in a separate commit.
        Hide
        ASF subversion and git services added a comment -

        Commit 1598138 from David Smiley in branch 'dev/trunk'
        [ https://svn.apache.org/r1598138 ]

        SOLR-6118: expand.sort bug for function queries; needed to sort.rewrite(searcher)

        Show
        ASF subversion and git services added a comment - Commit 1598138 from David Smiley in branch 'dev/trunk' [ https://svn.apache.org/r1598138 ] SOLR-6118 : expand.sort bug for function queries; needed to sort.rewrite(searcher)
        Hide
        ASF subversion and git services added a comment -

        Commit 1598147 from David Smiley in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1598147 ]

        SOLR-6118: expand.sort bug for function queries; needed to sort.rewrite(searcher)

        Show
        ASF subversion and git services added a comment - Commit 1598147 from David Smiley in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1598147 ] SOLR-6118 : expand.sort bug for function queries; needed to sort.rewrite(searcher)
        Hide
        David Smiley added a comment -

        FYI I also committed minor improvements pertaining to java 5 generics.

        Show
        David Smiley added a comment - FYI I also committed minor improvements pertaining to java 5 generics.
        Hide
        ASF subversion and git services added a comment -

        Commit 1598193 from David Smiley in branch 'dev/trunk'
        [ https://svn.apache.org/r1598193 ]

        SOLR-6118: CHANGES.txt

        Show
        ASF subversion and git services added a comment - Commit 1598193 from David Smiley in branch 'dev/trunk' [ https://svn.apache.org/r1598193 ] SOLR-6118 : CHANGES.txt
        Hide
        ASF subversion and git services added a comment -

        Commit 1598194 from David Smiley in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1598194 ]

        Merged from trunk
        SOLR-6118: CHANGES.txt [from revision 1598193]

        Show
        ASF subversion and git services added a comment - Commit 1598194 from David Smiley in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1598194 ] Merged from trunk SOLR-6118 : CHANGES.txt [from revision 1598193]

          People

          • Assignee:
            David Smiley
            Reporter:
            David Smiley
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development