arjansh commented on a change in pull request #229: Upgrade to Elasticsearch 7.3.1 URL: https://github.com/apache/metamodel/pull/229#discussion_r338918801
########## File path: elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/ElasticSearchRestDataContext.java ########## @@ -133,21 +142,24 @@ public ElasticSearchRestDataContext(final ElasticSearchRestClient client, String final List<SimpleTableDef> result = new ArrayList<>(); if (mappings.isEmpty()) { - logger.warn("No metadata returned for index name '{}' - no tables will be detected."); + logger.warn("No metadata returned for index name '{}' - no tables will be detected.", indexName); } else { - for (Entry<String, Object> mapping : mappings) { - final String documentType = mapping.getKey(); - - @SuppressWarnings("unchecked") - Map<String, Object> mappingConfiguration = (Map<String, Object>) mapping.getValue(); + for (final Entry<String, MappingMetaData> mapping : mappings.entrySet()) { + final String tableName = mapping.getValue().type(); + final Map<String, Object> mappingConfiguration = mapping.getValue().getSourceAsMap(); + @SuppressWarnings("unchecked") - Map<String, Object> properties = (Map<String, Object>) mappingConfiguration.get("properties"); - - try { - final SimpleTableDef table = detectTable(properties, documentType); - result.add(table); - } catch (Exception e) { - logger.error("Unexpected error during detectTable for document type '{}'", documentType, e); + final Map<String, Object> properties = (Map<String, Object>) mappingConfiguration.get(ElasticSearchMetaData.PROPERTIES_KEY); + + if (properties != null) { + try { + final SimpleTableDef table = detectTable(properties, tableName); + result.add(table); + } catch (Exception e) { + logger + .error("Unexpected error during detectTable for document mapping type '{}'", tableName, Review comment: On one line it's just over 120 characters, so my code formatter breaks it up into this, but it does look better on one line (and it's still under 130 characters on one line, so that's acceptable, so I'll manually put it on one line and make sure I don't format it). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services