spring-data-elasticsearch - registering custom analyser spring-data-elasticsearch - registering custom analyser elasticsearch elasticsearch

spring-data-elasticsearch - registering custom analyser


I guess you need to remove the field "settings": from json file and put only the content .

Instead of using :

{"settings": {    ....   }}

Just use :

{ "index": {"number_of_shards": 1,"analysis": {  "filter": {    "autocomplete_filter": {      "type": "edge_ngram",      "min_gram": 1,      "max_gram": 20    }  },  "analyzer": {    "autocomplete": {      "type": "custom",      "tokenizer": "standard",      "filter": [        "lowercase",        "autocomplete_filter"      ]     }    }   }   }}

Hope it helps you..


Solved

After some research I've discovered the problem was caused by this declaration:

@Beanpublic ElasticsearchOperations elasticsearchTemplate(Client client) {    return new ElasticsearchTemplate(client, new CustomEntityMapper());}

I removed this declaration and it began get the configuration.


I had a similar issue and this can occur due to multiple reasons:

  1. Make sure that your json file located at the samelocation as mentioned in the settingPath and its being getting read properly. To verify this as Richa said in the above just remove the analyzer from the json and test thenumber of shards created.
  2. In case the location is correct but stilljson file is not read then just check did you add @Document(indexName ="indexName", createIndex = false) annotation in the model classthen simply remove the createIndex = false from document annotation and then try again.
  3. Always remember to remove the old index and then test it again.