{"record":{"id":"cbbab6152c7b4f9b","repo":"prestodb/presto","slug":"elasticsearch-invalid-response","errorCode":"ELASTICSEARCH_INVALID_RESPONSE","errorMessage":"No mappings found for index: ","messagePattern":"No mappings found for index: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/client/ElasticsearchClient.java","lineNumber":537,"sourceCode":"                    // Older versions of ElasticSearch supported multiple \"type\" mappings\n                    // for a given index. Newer versions support only one and don't\n                    // expose it in the document. Here we skip it if it's present.\n\n                    if (!mappings.elements().hasNext()) {\n                        return new IndexMetadata(new IndexMetadata.ObjectType(ImmutableList.of()));\n                    }\n                    mappings = mappings.elements().next();\n                }\n\n                JsonNode metaNode = nullSafeNode(mappings, \"_meta\");\n\n                return new IndexMetadata(parseType(mappings.get(\"properties\"), nullSafeNode(metaNode, \"presto\")));\n            }\n            catch (IOException e) {\n                throw new PrestoException(ELASTICSEARCH_INVALID_RESPONSE, e);\n            }\n            catch (NoSuchElementException e) {\n                throw new PrestoException(ELASTICSEARCH_INVALID_RESPONSE, \"No mappings found for index: \" + index);\n            }\n        });\n    }\n\n    private IndexMetadata.ObjectType parseType(JsonNode properties, JsonNode metaProperties)\n    {\n        Iterator<Map.Entry<String, JsonNode>> entries = properties.fields();\n\n        ImmutableList.Builder<IndexMetadata.Field> result = ImmutableList.builder();\n        while (entries.hasNext()) {\n            Map.Entry<String, JsonNode> field = entries.next();\n\n            String name = field.getKey();\n            JsonNode value = field.getValue();\n\n            String type = \"object\";\n            if (value.has(\"type\")) {\n                type = value.get(\"type\").asText();","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-elasticsearch/src/main/java/com/facebook/presto/elasticsearch/client/ElasticsearchClient.java#L519-L555","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: querying unmapped index\nSELECT * FROM es.default.empty_index;\n// after: create mapping first\nPUT /empty_index { \"mappings\": { \"properties\": { \"name\": { \"type\": \"keyword\" } } } }","handlingStrategy":"try-catch","validationCode":"// confirm the index has mappings before querying\ncurl -s 'localhost:9200/<index>/_mapping' | jq '.[\"<index>\"].mappings.properties'\n# non-null properties means mappings exist","typeGuard":null,"tryCatchPattern":"try (Statement s = conn.createStatement()) {\n    ResultSet rs = s.executeQuery(\"SELECT * FROM es.default.idx LIMIT 1\");\n} catch (SQLException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"No mappings found for index\")) {\n        // create mapping or fix index/alias name, then retry\n    } else { throw e; }\n}","preventionTips":["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."],"tags":["elasticsearch","invalid-response","mappings","metadata"],"backgroundTag":"elasticsearch-invalid-response","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}