Created
October 21, 2011 12:32
-
-
Save anonymous/1303712 to your computer and use it in GitHub Desktop.
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
public void putMapping(String typeName, XContentBuilder mappingBuilder){ | |
System.out.println(" ----- > putMapping "); | |
try { | |
System.out.println(" >> taking index down --> " + this.globalIndexName); | |
getClient().admin().indices().prepareClose(globalIndexName).execute().actionGet(); | |
System.out.println(" >> sending PUT MAPPING : " ); | |
System.out.println(mappingBuilder.string()); | |
getClient().admin().indices() | |
.preparePutMapping().setType(typeName) | |
.setSource(mappingBuilder.string()).execute().actionGet(); | |
System.out.println( " >> waiting for green status .... >> "); | |
getClient().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); | |
//take index back up | |
System.out.println(" >> reopening index " + this.globalIndexName); | |
getClient().admin().indices().prepareOpen(globalIndexName).execute().actionGet(); | |
} catch (ElasticSearchException e) { | |
e.printStackTrace(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment