Uploaded image for project: 'Java Couchbase JVM Core'
  1. Java Couchbase JVM Core
  2. JVMCBC-1475

CoreTermSearchFacetResult.terms() returns null if field is absent from all documents

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.5.3
    • None
    • None
    • None
    • 1
    • SDK04: Scope Search

    Description

      Suggested Release Note:

      Accessing the terms of a `TermFacet` result no longer throws NullPointerException if the target field is absent from all documents.

       

      In Java, this surfaces as a NullPointerException when calling `TermSearchFacetResult.terms()`, as in this reproducer:

       

      SearchResult result = cluster.searchQuery(
        "global_vector_index_5b698e",
        SearchQuery.matchAll(),
        SearchOptions.searchOptions()
          .facets(mapOf("facetName", TermFacet.term("absent-field", 3)))
      );
       
      TermSearchFacetResult facetResult = (TermSearchFacetResult)
              result.facets().get("facetName");
       
      System.out.println(facetResult.terms()); // <--- NPE here

       

      It's worse in Kotlin, where the results are converted eagerly; Kotlin gets an NPE inside `searchQuery`, before the user even touches the facet results.

      Attachments

        For Gerrit Dashboard: JVMCBC-1475
        # Subject Branch Project Status CR V

        Activity

          People

            david.nault David Nault
            david.nault David Nault
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty