opensearch-project/OpenSearch

[BUG] Bitmap terms lookup throws NPE when stored lookup field is missing

Open

#21.995 aberto em 4 de jun. de 2026

Ver no GitHub
 (3 comments) (0 reactions) (0 assignees)Java (1.505 forks)batch import
Search:Query Capabilitiesbuggood first issue

Métricas do repositório

Stars
 (8.123 stars)
Métricas de merge de PR
 (Mesclagem média 5d 9h) (266 fundiu PRs em 30d)

Description

Describe the bug

A terms query using terms lookup with value_type: bitmap and store: true throws a server-side exception when the lookup document exists but the stored field at path is missing.

This should not fail with null_pointer_exception; it should behave as empty terms (no matches).

Related component

Search:Query Capabilities

To Reproduce

# cleanup
curl -s -X DELETE "http://localhost:9200/target_idx_bitmap_lookup,lookup_idx_bitmap_lookup"

# target index
curl -s -X PUT "http://localhost:9200/target_idx_bitmap_lookup" -H "Content-Type: application/json" -d '{
  "mappings": {
    "properties": {
      "user_id": { "type": "integer" }
    }
  }
}'

# lookup index (stored bitmap field)
curl -s -X PUT "http://localhost:9200/lookup_idx_bitmap_lookup" -H "Content-Type: application/json" -d '{
  "mappings": {
    "properties": {
      "bitmap_payload": { "type": "keyword", "store": true },
      "note": { "type": "keyword" }
    }
  }
}'

# lookup doc intentionally missing bitmap_payload
curl -s -X PUT "http://localhost:9200/lookup_idx_bitmap_lookup/_doc/1?refresh=true" -H "Content-Type: application/json" -d '{
  "note": "field intentionally missing"
}'

# target docs
curl -s -X POST "http://localhost:9200/target_idx_bitmap_lookup/_bulk?refresh=true" \
  -H "Content-Type: application/x-ndjson" \
  --data-binary $'{"index":{"_id":"1"}}\n{"user_id":1}\n{"index":{"_id":"2"}}\n{"user_id":2}\n'

# trigger terms lookup bitmap query
curl -s -X GET "http://localhost:9200/target_idx_bitmap_lookup/_search?pretty" -H "Content-Type: application/json" -d '{
  "query": {
    "terms": {
      "user_id": {
        "index": "lookup_idx_bitmap_lookup",
        "id": "1",
        "path": "bitmap_payload",
        "store": true
      },
      "value_type": "bitmap"
    }
  }
}'

Expected behavior

If the lookup field is missing, query rewrite should treat it as empty terms and return no hits (equivalent to match_none) without throwing NPE.

Additional Details

Plugins All default plugins in AWS opensearch when encountering the issue.

Host/Environment (please complete the following information):

  • OS: macOS
    • OpenSearch version/commit: AWS Opensearch 3.5. Tested also on latest opensearch, commit d5756a7f7fad279b85b39d23fe4d37db97e0b857

Guia do colaborador