@Override public Map getMapping(String indexName, String type) { Assert.notNull(indexName, "No index defined for putMapping()"); Assert.notNull(type, "No type defined for putMapping()"); Map mappings = null; try { GetMapping.Builder getMappingBuilder = new GetMapping.Builder(); getMappingBuilder.addIndex(indexName).addType(type); JestResult result = execute(getMappingBuilder.build()); if (!result.getJsonObject().has(indexName)) { logger.info("Index {} did not exist when retrieving mappings for type {}.", indexName, type); } else { JsonObject index = result.getJsonObject().get(indexName).getAsJsonObject(); if (index != null) { JsonObject mappingElem = index.get("mappings").getAsJsonObject(); if (!mappingElem.has(type)) { logger.info("Type {} did not exist in index {} when retrieving mappings.", type, indexName); } else { mappings = resultsMapper.getEntityMapper().mapToObject(mappingElem.get(type).toString(), Map.class); } } } } catch (Exception e) { throw new ElasticsearchException("Error while getting mapping for indexName : " + indexName + " type : " + type + " " + e.getMessage()); } return mappings; }