public static boolean createIndex(String appid, int shards, int replicas) {
if (StringUtils.isBlank(appid) || StringUtils.containsWhitespace(appid) || existsIndex(appid)) {
return false;
}
try {
NodeBuilder nb = NodeBuilder.nodeBuilder();
nb.settings().put("number_of_shards", Integer.toString(shards));
nb.settings().put("number_of_replicas", Integer.toString(replicas));
nb.settings().put("auto_expand_replicas", "0-all");
nb.settings().put("analysis.analyzer.default.type", "standard");
nb.settings().putArray("analysis.analyzer.default.stopwords",
"arabic", "armenian", "basque", "brazilian", "bulgarian", "catalan",
"czech", "danish", "dutch", "english", "finnish", "french", "galician",
"german", "greek", "hindi", "hungarian", "indonesian", "italian",
"norwegian", "persian", "portuguese", "romanian", "russian", "spanish",
"swedish", "turkish");
String name = appid + "1";
CreateIndexRequestBuilder create = getClient().admin().indices().prepareCreate(name).
setSettings(nb.settings().build());
// default system mapping (all the rest are dynamic)
create.addMapping("_default_", getDefaultMapping());
create.execute().actionGet();