I am trying to create an index in ES with a specific analyzer and mapping using JEST. I am using the following code:
CreateIndex createIndex = new CreateIndex.Builder(indexName) .settings( ImmutableSettings.builder() .loadFromClasspath( "jestconfiguration.json" ).build().getAsMap() ).build(); JestResult result = client.execute(createIndex);
And this is jestconfiguration.java
{ "settings": { "analysis": { "analyzer": { "second": { "type": "custom", "tokenizer": "standard", "filter": [ "lowercase", "synonym" ] } }, "filter": { "synonym" : { "type" : "synonym", "synonyms" : [ "smart phone => smartphone" ] } } } }, "mappings": { "index_type": { "properties": { "Name": { "type": "string", "analyzer": "second" } } } } }
As long as the index is sorted correctly with the specified “settings”, the “mappings” section does not work, and I cannot establish a mapping for the “Name” field. Does anyone have an idea? Is there something like putmapping() in JESt that allows you to add mappings? Ideally, I would like to be able to set the field_name dynamically, rather than in a .json file.
Thnks
source share