@Override public BulkNodeClient newMapping(String index, String type, Map<String, Object> mapping) { PutMappingRequestBuilder putMappingRequestBuilder = new PutMappingRequestBuilder(client.admin().indices()) .setIndices(index) .setType(type) .setSource(mapping); putMappingRequestBuilder.execute().actionGet(); logger.info("mapping created for index {} and type {}", index, type); return this; }
@Override public boolean putMapping(String indexName, String type, Object mapping) { Assert.notNull(indexName, "No index defined for putMapping()"); Assert.notNull(type, "No type defined for putMapping()"); PutMappingRequestBuilder requestBuilder = client.admin().indices().preparePutMapping(indexName).setType(type); if (mapping instanceof String) { requestBuilder.setSource(String.valueOf(mapping)); } else if (mapping instanceof Map) { requestBuilder.setSource((Map) mapping); } else if (mapping instanceof XContentBuilder) { requestBuilder.setSource((XContentBuilder) mapping); } return requestBuilder.execute().actionGet().isAcknowledged(); }