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

Clarify logic for term filters on numeric types



    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 6.4.1
    • 6.5, 7.0
    • faceting
    • None


      The following code has been found to be confusing to multiple folks working in SimpleFacets.java (see SOLR-10132)

      if (termFilter != null) {
                    // TODO: understand this logic... what is the case for supporting an empty string
                    // for contains on numeric facets? What does that achieve?
                    // The exception message is misleading in the case of an excludeTerms filter in any case...
                    // Also maybe vulnerable to NPE on isEmpty test?
                    final boolean supportedOperation = (termFilter instanceof SubstringBytesRefFilter) && ((SubstringBytesRefFilter) termFilter).substring().isEmpty();
                    if (!supportedOperation) {
                      throw new SolrException(ErrorCode.BAD_REQUEST, FacetParams.FACET_CONTAINS + " is not supported on numeric types");

      This is found around line 482 or so. The comment in the code above is mine, and won't be found in the codebase. This ticket can be resolved by eliminating the complex check and just denying all termFilters with a better exception message not specific to contains filters (and perhaps consolidated with the proceeding check for about prefix filters?), or adding a comment to the code base explaining why we need to allow a term filter with an empty, non-null string to be processed, and why this isn't an NPE waiting to happen.


        1. SOLR-10155.patch
          2 kB
          Christine Poerschke
        2. SOLR-10155.patch
          1 kB
          Christine Poerschke

        Issue Links



              cpoerschke Christine Poerschke
              gus Gus Heck
              0 Vote for this issue
              5 Start watching this issue