Created
June 25, 2015 23:25
-
-
Save alexcheng1982/52c7237c061d380fb001 to your computer and use it in GitHub Desktop.
Elasticsearch - Create index when not exist
This file contains hidden or 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
private void createIndex() { | |
boolean indexExists = client.admin().indices().prepareExists(INDEX_NAME).execute().actionGet().isExists(); | |
if (!indexExists) { | |
if (LOGGER.isInfoEnabled()) { | |
LOGGER.info("Index {} doesn't exist, create it now.", INDEX_NAME); | |
} | |
client.admin().indices().prepareCreate(INDEX_NAME).execute(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment