Error Log: This error happens during indexing (writing a document) and is a very common part of a bulk request failure:
{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "failed to parse field [http_response_code] of type [long] in document with id '...'.
Preview of field's value: 'N/A'"
}
],
"type" : "mapper_parsing_exception",
"reason" : "failed to parse field [http_response_code]...",
"caused_by" : {
"type" : "number_format_exception",
"reason" : "For input string: \"N/A\""
}
},
"status" : 400
}
Why… is this happening? A MapperParsingException means you are sending data that does not match the schema (called the “mapping”) for your index.
In the example above:
- The index mapping defines the field
http_response_codeas along(a number). - The application tried to send a document where
http_response_codehad the value"N/A"(a string). - OpenSearch cannot store the text string
"N/A"in a field that is only for numbers, so it rejects the document and throws this error.
This is the most common data-quality issue new users face.
Best Practice:
- Check Your Mapping: First, understand what OpenSearch expects. Use
GET /my-index-name/_mappingto see the data type(long, keyword, text, boolean, etc.)for the field in question. - Clean Your Data (Best Solution): The best fix is to “clean” the data at the source. Your application (e.g., Logstash, Filebeat, or your custom code) should standardize this data before sending it to OpenSearch. For example, change
"N/A"tonullor a specific number like0. - Fix Your Mapping (If Necessary): If you must store both numbers and strings in the same field, you must re-index. Create a new index where that field is mapped as
keyword(for exact strings) ortext(for full-text search). You cannot change the mapping of an existing field.
What else can I do? Unsure how to clean your data or how to re-index with a new mapping? Ask the OpenSearch community! Show them your data sample and your mapping, and they can provide the best path forward. For detailed help, reach out to the vibrant OpenSearch community for help and support on the OpenSearch Slack Channel.