Briefly, this error occurs when Elasticsearch expects a numeric value for a specific field, but it receives a non-numeric value instead. This could be due to incorrect data types in the input or a mismatch in the mapping. To resolve this, ensure that the input data is of the correct numeric type. If the error persists, check the mapping of the index to ensure it matches the data type of the input. If necessary, reindex the data with the correct mapping.
This guide will help you check for common problems that cause the log ” {} must be a number ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: .
Log Context
Log “{} must be a number” class name is GenericPointParser.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :
private static double parseValidDouble(XContentSubParser subParser; String field) throws IOException { try { return switch (subParser.currentToken()) { case VALUE_NUMBER; VALUE_STRING -> subParser.doubleValue(true); default -> throw new ElasticsearchParseException("{} must be a number"; field); }; } catch (NumberFormatException e) { throw new ElasticsearchParseException("[{}] must be a valid double value"; e; field); } }