prestodb/presto · error · PrestoException
ELASTICSEARCH_INVALID_RESPONSE
ELASTICSEARCH_INVALID_RESPONSE
Error message
No mappings found for index:
What it means
getIndexMetadata fetches the index mapping from Elasticsearch and reads the 'mappings' node. If the response has no mappings data (NoSuchElementException while navigating the JSON), the connector throws a PrestoException with code ELASTICSEARCH_INVALID_RESPONSE, meaning the response could not be interpreted as index metadata rather than a network failure.
Source
Thrown at presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/client/ElasticsearchClient.java:537
// Older versions of ElasticSearch supported multiple "type" mappings
// for a given index. Newer versions support only one and don't
// expose it in the document. Here we skip it if it's present.
if (!mappings.elements().hasNext()) {
return new IndexMetadata(new IndexMetadata.ObjectType(ImmutableList.of()));
}
mappings = mappings.elements().next();
}
JsonNode metaNode = nullSafeNode(mappings, "_meta");
return new IndexMetadata(parseType(mappings.get("properties"), nullSafeNode(metaNode, "presto")));
}
catch (IOException e) {
throw new PrestoException(ELASTICSEARCH_INVALID_RESPONSE, e);
}
catch (NoSuchElementException e) {
throw new PrestoException(ELASTICSEARCH_INVALID_RESPONSE, "No mappings found for index: " + index);
}
});
}
private IndexMetadata.ObjectType parseType(JsonNode properties, JsonNode metaProperties)
{
Iterator<Map.Entry<String, JsonNode>> entries = properties.fields();
ImmutableList.Builder<IndexMetadata.Field> result = ImmutableList.builder();
while (entries.hasNext()) {
Map.Entry<String, JsonNode> field = entries.next();
String name = field.getKey();
JsonNode value = field.getValue();
String type = "object";
if (value.has("type")) {
type = value.get("type").asText();View on GitHub (pinned to 55bb57d202)
Solutions
- Verify mappings exist: curl -X GET 'localhost:9200/<index>/_mapping' and inspect the JSON.
- If the index is empty/unmapped, write documents first or define explicit mappings before querying from Presto.
- Check you are targeting the correct index/alias name in the schema.table.
- Ensure connector and Elasticsearch versions are compatible; upgrade the connector for newer ES versions.
Example fix
// before: querying unmapped index
SELECT * FROM es.default.empty_index;
// after: create mapping first
PUT /empty_index { "mappings": { "properties": { "name": { "type": "keyword" } } } } Defensive patterns
Strategy: try-catch
Validate before calling
// confirm the index has mappings before querying curl -s 'localhost:9200/<index>/_mapping' | jq '.["<index>"].mappings.properties' # non-null properties means mappings exist
Try / catch
try (Statement s = conn.createStatement()) {
ResultSet rs = s.executeQuery("SELECT * FROM es.default.idx LIMIT 1");
} catch (SQLException e) {
if (e.getMessage() != null && e.getMessage().contains("No mappings found for index")) {
// create mapping or fix index/alias name, then retry
} else { throw e; }
} Prevention
- Verify GET /<index>/_mapping returns properties before registering the table.
- Target concrete indices or well-defined aliases, not empty patterns.
- Write at least one document (or a PUT mapping) before querying new indices.
When it happens
Trigger: Querying an index (or alias/data stream) whose GET /{index}/_mapping response lacks a mappings object — e.g. empty index never mapped, hidden/system index, or Elasticsearch version returning a different response shape than expected.
Common situations: Pointing the schema/table at an alias that resolves to zero or unexpected indices; Elasticsearch version upgrade changing mapping response layout; querying data streams where the connector's path assumptions break.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/cbbab6152c7b4f9b.
Report an issue: GitHub.