elastic/elasticsearch · error · ParsingException

[bitmap_terms] requires a [field]

Error message

[bitmap_terms] requires a [field]

What it means

Thrown after parsing completes if no "field" key was supplied. bitmap_terms requires a target field name; the parser collects keys and then validates presence, failing with ParsingException when fieldName is still null.

Source

Thrown at modules/bitmap/src/main/java/org/elasticsearch/index/query/bitmapterms/BitmapTermsQueryBuilder.java:136

                } else if (BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
                    boost = parser.floatValue();
                } else if (NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
                    queryName = parser.text();
                } else {
                    throw new ParsingException(
                        parser.getTokenLocation(),
                        "[" + NAME + "] query does not support [" + currentFieldName + "]"
                    );
                }
            } else {
                throw new ParsingException(
                    parser.getTokenLocation(),
                    "[" + NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]"
                );
            }
        }
        if (fieldName == null) {
            throw new ParsingException(parser.getTokenLocation(), "[" + NAME + "] requires a [field]");
        }
        if (value == null) {
            throw new ParsingException(parser.getTokenLocation(), "[" + NAME + "] requires a [value]");
        }
        return new BitmapTermsQueryBuilder(fieldName, value).boost(boost).queryName(queryName);
    }

    @Override
    public String getWriteableName() {
        return NAME;
    }

    @Override
    protected Query doToQuery(SearchExecutionContext context) throws IOException {
        MappedFieldType fieldType = context.getFieldType(fieldName);
        if (!(fieldType instanceof NumberFieldMapper.NumberFieldType numberFieldType)
            || (numberFieldType.numberType() != NumberFieldMapper.NumberType.INTEGER
                && numberFieldType.numberType() != NumberFieldMapper.NumberType.LONG)

View on GitHub (pinned to db6a809a66)

Solutions

  1. Add the "field" key with the target numeric field name.
  2. Validate the query body contains both field and value before submitting the search request.

Example fix

// before
{"bitmap_terms":{"value":"PGJpdG1hcD4="}}
// after
{"bitmap_terms":{"field":"uid","value":"PGJpdG1hcD4="}}
Defensive patterns

Strategy: validation

Validate before calling

if (!body.field || typeof body.field !== "string") {
  throw new Error("bitmap_terms requires a [field]");
}

Prevention

When it happens

Trigger: Sending `{"bitmap_terms":{"value":"..."}}` (field omitted), or an empty `{"bitmap_terms":{}}`. Any body missing the "field" key triggers it after the parse loop.

Common situations: Building the query body programmatically and skipping the field assignment on a conditional branch; templating that drops empty fields.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/f0efd07290a96ce5. Report an issue: GitHub.