Hi all,
Before, in ElasticSearch 2.3.1, I was checking if some index existed and if not I was making a PUT request to create it with my settings and my mappings, just like below:
String synonymFiltersName = "filtro_de_sinonimos";
String synonymAnalyzerName = "analizador_sinonimos";
public String generateIndexJSON() throws IOException {
XContentBuilder settingsBuilder = XContentFactory.jsonBuilder()
.startObject()
.startObject("settings")
.startObject("index")
.field("number_of_shards",3)
.field("number_of_replicas",0)
.field("sort.field", Const.COL_DATA_HORA)
.field("sort.order", "asc")
.endObject()
.startObject("analysis")
.startObject("filter")
.startObject("portuguese_stop")
.field("type","stop")
.field("stopwords","_portuguese_")
.endObject()
.startObject("portuguese_stemmer")
.field("type","stemmer")
.field("language","light_portuguese")
.endObject()
.startObject(synonymFiltersName)
.field("type","synonym")
.startArray("synonyms")
.value("deletar => deletar,excluir,apagar,remover")
.value("salvar => salvar,atualizar")
.value("email,mail,imail")
.value("administrador => admin,administrador,super")
.endArray()
.endObject()
.endObject() // filter
.startObject("analyzer")
.startObject(synonymAnalyzerName)
.field("tokenizer", "standard")
.array("filter","lowercase","portuguese_stop","portuguese_stemmer", synonymFiltersName)
.endObject()
.endObject() // analyzer
.endObject()
.endObject()
.startObject("mappings")
.startObject(Const.LOG_INDEX_NAME)
.startObject("_all")
.field("type", "string")
.field("index", "analyzed")
.field("analyzer", "portuguese")
.endObject()
.startObject("properties") // configuração dos campos/atributos
.startObject(Const.COL_DATA_HORA)
.field("type", "date")
.field("index", "analyzed")
.field("format",Const.FORMATO_COL_DATA_HORA)
.endObject() // dataHora
.startObject("id")
.field("type", "integer")
.field("index", "analyzed")
.startObject("fields")
.startObject("original")
.field("type", "integer")
.field("index", "not_analyzed")
.endObject()
.endObject()
.endObject() // idUsuario
.startObject(Const.COL_OPERACAO)
.field("type", "string")
.field("index", "analyzed")
.field("analyzer", "portuguese")
.field("search_analyzer", synonymAnalyzerName)
.startObject("fields")
.startObject("original")
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
.endObject()
.endObject() // operacao
.startObject(Const.COL_SERVICO)
.field("type", "string")
.field("index", "analyzed")
.field("analyzer", "portuguese")
.startObject("fields")
.startObject("original")
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
.endObject()
.endObject() // nomeServico
.startObject(Const.COL_CLIENTE)
.field("type", "string")
.field("index", "analyzed")
.field("analyzer", "portuguese")
.field("search_analyzer", synonymAnalyzerName)
.startObject("fields")
.startObject("original")
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
.endObject()
.endObject() // nomeCliente
.startObject(Const.COL_USUARIO)
.field("type", "string")
.field("index", "analyzed")
.field("analyzer", "portuguese")
.field("search_analyzer", synonymAnalyzerName)
.startObject("fields")
.startObject("original")
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
.endObject()
.endObject() // nomeUsuario
.startObject(Const.COL_EMAIL)
.field("type", "string")
.field("index", "analyzed")
.field("analyzer", "portuguese")
.startObject("fields")
.startObject("original")
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
.endObject()
.endObject() // emailUsuario
.endObject() // properties
.endObject()
.endObject()
.endObject();
String json = Strings.toString(settingsBuilder);
Now, in version 7.5.1, I do the same request but it doesn't create the complete configuration I need:
My question is, how can I do the same thing using this new version?
Also, where can I find documentation about ElasticSearch API calls?
Is there something like Kopf plugin for this new version? How can I manipulate the settings?