{"record":{"id":"f0efd07290a96ce5","repo":"elastic/elasticsearch","slug":"bitmap-terms-requires-a-field","errorCode":null,"errorMessage":"[bitmap_terms] requires a [field]","messagePattern":"\\[bitmap_terms\\] requires a \\[field\\]","errorType":"validation","errorClass":"ParsingException","httpStatus":400,"severity":"error","filePath":"modules/bitmap/src/main/java/org/elasticsearch/index/query/bitmapterms/BitmapTermsQueryBuilder.java","lineNumber":136,"sourceCode":"                } else if (BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {\n                    boost = parser.floatValue();\n                } else if (NAME_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {\n                    queryName = parser.text();\n                } else {\n                    throw new ParsingException(\n                        parser.getTokenLocation(),\n                        \"[\" + NAME + \"] query does not support [\" + currentFieldName + \"]\"\n                    );\n                }\n            } else {\n                throw new ParsingException(\n                    parser.getTokenLocation(),\n                    \"[\" + NAME + \"] unknown token [\" + token + \"] after [\" + currentFieldName + \"]\"\n                );\n            }\n        }\n        if (fieldName == null) {\n            throw new ParsingException(parser.getTokenLocation(), \"[\" + NAME + \"] requires a [field]\");\n        }\n        if (value == null) {\n            throw new ParsingException(parser.getTokenLocation(), \"[\" + NAME + \"] requires a [value]\");\n        }\n        return new BitmapTermsQueryBuilder(fieldName, value).boost(boost).queryName(queryName);\n    }\n\n    @Override\n    public String getWriteableName() {\n        return NAME;\n    }\n\n    @Override\n    protected Query doToQuery(SearchExecutionContext context) throws IOException {\n        MappedFieldType fieldType = context.getFieldType(fieldName);\n        if (!(fieldType instanceof NumberFieldMapper.NumberFieldType numberFieldType)\n            || (numberFieldType.numberType() != NumberFieldMapper.NumberType.INTEGER\n                && numberFieldType.numberType() != NumberFieldMapper.NumberType.LONG)","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/bitmap/src/main/java/org/elasticsearch/index/query/bitmapterms/BitmapTermsQueryBuilder.java#L118-L154","documentation":"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.","triggerScenarios":"Sending `{\"bitmap_terms\":{\"value\":\"...\"}}` (field omitted), or an empty `{\"bitmap_terms\":{}}`. Any body missing the \"field\" key triggers it after the parse loop.","commonSituations":"Building the query body programmatically and skipping the field assignment on a conditional branch; templating that drops empty fields.","solutions":["Add the \"field\" key with the target numeric field name.","Validate the query body contains both field and value before submitting the search request."],"exampleFix":"// before\n{\"bitmap_terms\":{\"value\":\"PGJpdG1hcD4=\"}}\n// after\n{\"bitmap_terms\":{\"field\":\"uid\",\"value\":\"PGJpdG1hcD4=\"}}","handlingStrategy":"validation","validationCode":"if (!body.field || typeof body.field !== \"string\") {\n  throw new Error(\"bitmap_terms requires a [field]\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set field and value together before constructing the query.","Unit-test the query builder to assert field/value are non-null."],"tags":["bitmap-terms","query-dsl","parsing","elasticsearch"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}