title: spring-data-elasticsearch - registering custom analyser
body: <p>I'm trying to use ElasticSearch in my application for full text search and at this time I'm trying use <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/_index_time_search_as_you_type.html" rel="noreferrer">autocomplete analyser</a>:</p>
  
  <pre><code>{
      "settings": {
          "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"
                      ]
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>As my application was constructed with Spring, I've decided use Spring-data-elasticsearch and mapped my entity this way:</p>
  
  <pre><code>@Document(indexName = "estabelecimento")
  @Setting(settingPath = "/elasticsearch/autocomplete-analyser.json")
  public class ESEstabelecimento {
  
      private Long id;
      @Field(type = FieldType.String, indexAnalyzer = "autocomplete")
      private String nome;
      private String razaoSocial;
      private String tipoEstabelecimento;
      @Field(type = FieldType.Object)
      private ESCidade cidade;
  }
  </code></pre>
  
  <p>However, elasticsearch isn't loading the custom analyser:</p>
  
  <blockquote>
    <p>[DEBUG] org.elasticsearch.action.admin.indices.mapping.put - [Magus] failed to put mappings on indices [[estabelecimento]], type [esestabelecimento]
    org.elasticsearch.index.mapper.MapperParsingException: Analyzer [autocomplete] not found for field [nome]
        at org.elasticsearch.index.mapper.core.TypeParsers.parseField(TypeParsers.java:220) ~[elasticsearch-1.5.2.jar:na]
        at org.elasticsearch.index.mapper.core.StringFieldMapper$TypeParser.parse(StringFieldMapper.java:153) ~[elasticsearch-1.5.2.jar:na]
        at org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:290) ~[elasticsearch-1.5.2.jar:na]
        at org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseObjectOrDocumentTypeProperties(ObjectMapper.java:214) ~[elasticsearch-1.5.2.jar:na]
        at org.elasticsearch.index.mapper.object.RootObjectMapper$TypeParser.parse(RootObjectMapper.java:136) ~[elasticsearch-1.5.2.jar:na]
        at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:211) ~[elasticsearch-1.5.2.jar:na]
        at org.elasticsearch.index.mapper.DocumentMapperParser.parseCompressed(DocumentMapperParser.java:192) ~[elasticsearch-1.5.2.jar:na]
        at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:434) ~[elasticsearch-1.5.2.jar:na]
        at org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:505) ~[elasticsearch-1.5.2.jar:na]
        at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:365) ~[elasticsearch-1.5.2.jar:na]
        at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:188) [elasticsearch-1.5.2.jar:na]
        at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:158) [elasticsearch-1.5.2.jar:na]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_77]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_77]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_77]
    [ERROR] org.springframework.data.elasticsearch.repository.support.AbstractElasticsearchRepository - failed to load elasticsearch nodes : org.elasticsearch.index.mapper.MapperParsingException: Analyzer [autocomplete] not found for field [nome]</p>
  </blockquote>
  
  <p>I can't identify the cause of the problem, I don't know if the analyser is invalid or elasticsearch even found the autocomplete-analyser.json file. How can I solve this?</p>