Details
-
Bug
-
Resolution: Fixed
-
Major
-
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.