prestodb/presto · error · PrestoException
ELASTICSEARCH_TYPE_MISMATCH
ELASTICSEARCH_TYPE_MISMATCH
Error message
Expected a boolean value for field %s of type BOOLEAN: %s [%s]
What it means
BooleanDecoder decodes a field declared as BOOLEAN. Null decodes to NULL and a genuine Boolean is written directly; any other value (string like "true"/"false", number) throws PrestoException(ELASTICSEARCH_TYPE_MISMATCH) because the value cannot be interpreted as a boolean.
Source
Thrown at presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/decoders/BooleanDecoder.java:48
private final String path;
public BooleanDecoder(String path)
{
this.path = requireNonNull(path, "path is null");
}
@Override
public void decode(Hit hit, Supplier<Object> getter, BlockBuilder output)
{
Object value = getter.get();
if (value == null) {
output.appendNull();
}
else if (value instanceof Boolean) {
BOOLEAN.writeBoolean(output, (Boolean) value);
}
else {
throw new PrestoException(ELASTICSEARCH_TYPE_MISMATCH, format("Expected a boolean value for field %s of type BOOLEAN: %s [%s]", path, value, value.getClass().getSimpleName()));
}
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Fix documents to store real JSON booleans (true/false, unquoted).
- Change the Presto column to VARCHAR if the underlying data is strings, and cast in queries.
- Normalize the ingestion pipeline to emit native booleans.
- Reindex with an ingest pipeline converting strings to booleans.
Example fix
// before (document)
{ "is_active": "true" }
// after
{ "is_active": true } Defensive patterns
Strategy: validation
Validate before calling
// find documents whose boolean field is a string
curl -s 'localhost:9200/<index>/_search' -H 'Content-Type: application/json' -d '{
"query": { "script": { "script": {
"source": "doc.containsKey(\"is_active\") && !(doc[\"is_active\"].value instanceof Boolean)"
} } } }' Try / catch
try {
rs = stmt.executeQuery("SELECT is_active FROM es.default.idx");
} catch (PrestoException e) {
if (e.getErrorCode().getName().equals("ELASTICSEARCH_TYPE_MISMATCH")) {
// reindex with a script converting "true"/"false" strings to booleans
} else { throw e; }
} Prevention
- Emit native JSON booleans from ingestion code (unquoted true/false).
- Add an ES ingest pipeline with a boolean convert processor for CSV sources.
- Align the Presto column type (BOOLEAN vs VARCHAR) with the actual mapping.
When it happens
Trigger: A document stores a non-boolean value (e.g. "active": "true" as a string, or "active": 1) in a field declared BOOLEAN in the Presto schema; thrown during row decoding.
Common situations: Documents ingested from CSV/JSON pipelines that serialize booleans as strings; dynamic mapping inferred boolean in one document, string in another; Presto schema ahead of actual data types.
Related errors
- ELASTICSEARCH_TYPE_MISMATCH
- ELASTICSEARCH_TYPE_MISMATCH
- ELASTICSEARCH_TYPE_MISMATCH
- ELASTICSEARCH_TYPE_MISMATCH
- ELASTICSEARCH_TYPE_MISMATCH
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/38a9179c76bbfcc8.
Report an issue: GitHub.