Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Updating a ElasticSearch Document
public void createUpdateDocument(String index, String type, String docJson, String id) throws IOException {
Index esIndex;
if (id == null) {
esIndex = new Index.Builder(docJson).index(index).type(type).build();
} else {
esIndex = new Index.Builder(docJson).index(index).type(type).id(id).build();
}
JestResult jestResult = esClient.execute(esIndex);
if(jestResult.isSucceeded()) {
logger.info("Document persisted");
}
else {
logger.error(jestResult);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment