How to add mapping in ElasticSearch using JEST
I found your question while trying to see if I could create an index and mappings in one go. I ended up just creating a second request for creating mappings.
String mappingJson = new String(ByteStreams.toByteArray(mappingFile.getInputStream())); boolean indexExists = client.execute(new IndicesExists.Builder(configuration.getIndex()).build()).isSucceeded(); if (indexExists) { logger.info("Updating elasticsearch type mapping."); client.execute(new PutMapping.Builder(configuration.getIndex(), configuration.getBaseType(), mappingJson).build()); } else { logger.info("Creating elasticsearch index and type mapping."); client.execute(new CreateIndex.Builder(configuration.getIndex()).build()); client.execute(new PutMapping.Builder(configuration.getIndex(), configuration.getBaseType(), mappingJson).build()); }