Created
October 21, 2011 12:16
-
-
Save anonymous/1303673 to your computer and use it in GitHub Desktop.
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
//CREATE INDEX is called the beginning of framework startup | |
private void createIndex(){ | |
System.out.println("ElasticStore : preparing index " + globalIndexName); | |
boolean exists = getClient().admin().indices().prepareExists(globalIndexName).execute().actionGet().exists(); | |
if( !exists){ | |
Map<String,Object> settings = new HashMap<String, Object>(); | |
settings.put(NUMBER_OF_REPLICAS_PROP_KEY, this.numberOfReplicas); | |
settings.put(NUMBER_OF_SHARDS_PROP_KEY, this.numberOfShards); | |
System.out.println(" >> Index did not exist , creating it "); | |
getClient().admin().indices().prepareCreate(globalIndexName) | |
.setSettings(settings) | |
.execute().actionGet(); | |
getClient().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); | |
System.out.println(" >> index should have been created "); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment