Solr
  1. Solr
  2. SOLR-7046

NullPointerException when group.function uses query() function

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.10.3
    • Fix Version/s: 5.1, 6.0
    • Component/s: search
    • Labels:
      None

      Description

      When you attempt to group by function using the query() function, it results in an NullPointerException.

      Using the example webapp loaded with the hd.xml file in exampledocs, you can recreate by issuing the following query:

      http://localhost:8983/solr/select/?q=*:*&group=true&group.func=ceil(query(

      {!type=edismax%20v=$q}

      ))

      This appears to be due to a small bug in the following file:

      Grouping.java
          protected void prepare() throws IOException {
            Map context = ValueSource.newContext(searcher);
            groupBy.createWeight(context, searcher);
            actualGroupsToFind = getMax(offset, numGroups, maxDoc);
          }
      

      The variable context is always null because it's scope is local to this function, but it gets passed on to another function later.

      The patch is simply removing the Map qualifier from the instantiation.

      1. SOLR-7046.patch
        1 kB
        Erick Erickson
      2. SOLR-7046.patch
        0.6 kB
        Jim Musil

        Activity

        Hide
        Erick Erickson added a comment -

        This seems very straightforward, as Jim says just a bug with a trivial fix.
        Absent objections I'll commit this Real Soon Now.

        Show
        Erick Erickson added a comment - This seems very straightforward, as Jim says just a bug with a trivial fix. Absent objections I'll commit this Real Soon Now.
        Hide
        Erick Erickson added a comment -

        Same patch with CHANGES.txt

        Show
        Erick Erickson added a comment - Same patch with CHANGES.txt
        Hide
        ASF subversion and git services added a comment -

        Commit 1655525 from Erick Erickson in branch 'dev/trunk'
        [ https://svn.apache.org/r1655525 ]

        SOLR-7046: NullPointerException when group.function uses query() function

        Show
        ASF subversion and git services added a comment - Commit 1655525 from Erick Erickson in branch 'dev/trunk' [ https://svn.apache.org/r1655525 ] SOLR-7046 : NullPointerException when group.function uses query() function
        Hide
        ASF subversion and git services added a comment -

        Commit 1655535 from Erick Erickson in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1655535 ]

        SOLR-7046: NullPointerException when group.function uses query() function

        Show
        ASF subversion and git services added a comment - Commit 1655535 from Erick Erickson in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1655535 ] SOLR-7046 : NullPointerException when group.function uses query() function
        Hide
        Erick Erickson added a comment -

        Thanks Jim!

        Show
        Erick Erickson added a comment - Thanks Jim!
        Hide
        Timothy Potter added a comment -

        Bulk close after 5.1 release

        Show
        Timothy Potter added a comment - Bulk close after 5.1 release

          People

          • Assignee:
            Erick Erickson
            Reporter:
            Jim Musil
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development