Solr
  1. Solr
  2. SOLR-3150

NPE when facetting using facet.prefix on an "empty" field

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0-ALPHA
    • Fix Version/s: 4.0-ALPHA
    • Component/s: None
    • Labels:
      None

      Description

      FacetComponent works fine on empty fields but crashes if facet.prefix parameter is set.

      Looking at the code : getOrdTermsEnum(..) returns null if no value is found on the field but getCounts(...) does not checks if TermsEnum te is null or not.

      UnInvertedField.java (getCounts(..))
            TermsEnum te = getOrdTermsEnum(searcher.getAtomicReader());
            if (prefix != null && prefix.length() > 0) {
              final BytesRef prefixBr = new BytesRef(prefix);
      232:    if (te.seekCeil(prefixBr, true) == TermsEnum.SeekStatus.END) {
                startTerm = numTermsInField;
              } else {
                startTerm = (int) te.ord();
              }
              prefixBr.append(UnicodeUtil.BIG_TERM);
              if (te.seekCeil(prefixBr, true) == TermsEnum.SeekStatus.END) {
                endTerm = numTermsInField;
              } else {
                endTerm = (int) te.ord();
              }
            }
      
      java.lang.NullPointerException
      	at org.apache.solr.request.UnInvertedField.getCounts(UnInvertedField.java:232)
      	at org.apache.solr.request.SimpleFacets.getTermCounts(SimpleFacets.java:299)
      	at org.apache.solr.request.SimpleFacets.getFacetFieldCounts(SimpleFacets.java:354)
      	at org.apache.solr.request.SimpleFacets.getFacetCounts(SimpleFacets.java:207)
      	at org.apache.solr.handler.component.FacetComponent.process(FacetComponent.java:81)
      

        Issue Links

          Activity

          Pablo Queixalos created issue -
          Hide
          Yonik Seeley added a comment -

          Hmmm, this used to work.
          A quick look suggests this was broken by LUCENE-3003

          Show
          Yonik Seeley added a comment - Hmmm, this used to work. A quick look suggests this was broken by LUCENE-3003
          Yonik Seeley made changes -
          Field Original Value New Value
          Assignee Yonik Seeley [ yseeley@gmail.com ]
          Yonik Seeley made changes -
          Link This issue is broken by LUCENE-3003 [ LUCENE-3003 ]
          Hide
          Yonik Seeley added a comment -

          Fix committed. Thanks Pablo!

          Show
          Yonik Seeley added a comment - Fix committed. Thanks Pablo!
          Yonik Seeley made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Uwe Schindler made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          3h 29m 1 Yonik Seeley 21/Feb/12 20:53
          Resolved Resolved Closed Closed
          443d 13h 46m 1 Uwe Schindler 10/May/13 10:40

            People

            • Assignee:
              Yonik Seeley
              Reporter:
              Pablo Queixalos
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development