Fix NPE in bitmap terms lookup when stored field is missing#22208
Fix NPE in bitmap terms lookup when stored field is missing#22208kshitizj03 wants to merge 1 commit into
Conversation
A terms query using terms lookup with value_type: bitmap and store: true threw a NullPointerException when the looked-up document existed but the stored field at `path` was absent. GetResponse.getField(path) returns null for an absent stored field, and getValues() was called on it unconditionally. Guard the null DocumentField and treat a missing stored field as no terms (no matches), which matches the behavior for a missing source field. Fixes opensearch-project#21995 Signed-off-by: Kshitiz Jain <kshitizj@gmail.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
❌ Gradle check result for 3b8d5e2: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
The gradle-check failure looks like an unrelated CI flake rather than a real test failure. The failing task is The Jenkins run also reports "Test Result (no failures)", and Could a maintainer please re-run gradle-check? Thanks! |
Description
A
termsquery using terms lookup withvalue_type: bitmapandstore: truethrows aNullPointerExceptionwhen the looked-up document exists but the stored field atpathismissing.
Root cause: in
TermsQueryBuilder#fetch,getResponse.getField(termsLookup.path())returnsnullfor an absent stored field, andgetValues()was called on it unconditionally.This change guards the null
DocumentFieldand treats a missing stored field as no terms(no matches), which is consistent with how a missing source field is already handled. Existing
single-value bitmap validation is preserved for the present-field case.
Added a REST yaml test in
search/380_bitmap_filtering.yml: a lookup document missing the storedbitmap field now returns
hits.total: 0instead of erroring.Related Issues
Resolves #21995
Check List