Created
April 10, 2016 06:07
-
-
Save suresk/38012ca8845019a9a8ef09e2659627d8 to your computer and use it in GitHub Desktop.
Elasticsearch put mapping
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
String mapping = getMapFile(aliasName); | |
if(mapping != null) | |
{ | |
elasticClient.admin().indices().putMapping(new PutMappingRequest(indexName).source(getMapFile(aliasName))); | |
} | |
... | |
private String getMapFile(String aliasName) | |
{ | |
InputStream is = AliasingRebuildService.class.getResourceAsStream(String.format("/mappings/%s.json", aliasName)); | |
try | |
{ | |
if(is == null) | |
{ | |
return null; | |
} | |
return IOUtils.toString(is); | |
} | |
catch(Exception e) | |
{ | |
throw new RuntimeException(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment