Last active
May 21, 2020 08:26
-
-
Save talfco/eb8ab20bfafe2359b120668d5655dcc1 to your computer and use it in GitHub Desktop.
Updating a ElasticSearch Document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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