title: spring data elasticsearch: settings and mapping config with annotations not working
body: <p>I'm using embedded elasticsearch with spring boot and I was trying to use annotations for configuring settings and mappings. I followed this <a href="https://qbox.io/blog/multi-field-partial-word-autocomplete-in-elasticsearch-using-ngrams" rel="noreferrer">Tutorial</a> which explains how to implement searching over multiple fields. Anyway, I have defined the settings.json and the mappings.json in my document entity as described <a href="https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/springframework/data/elasticsearch/entities/DynamicSettingAndMappingEntity.java" rel="noreferrer">here</a> but it seems as if it is not reading the files because curl<em>ing</em> the mappings does not return the corresponding configuration as defined in the files.</p>
  
  <p>Indexing is been executed by a spring batch process. It reads data from the database and writes it to elasticsearch. This works perfectly.</p>
  
  <p>I get no results (should return 7 items) when I make a POST request to <a href="http://localhost:9200/profile/_search" rel="noreferrer">http://localhost:9200/profile/_search</a>:</p>
  
  <pre><code>{
     "size": 10,
     "query": {
         "match": {
         "_all": {
             "query": "user male",
             "operator": "and"
         }
      }
    }
  }
  </code></pre>
  
  <p>If I change the query to "user5" it returns the user with this nickname.</p>
  
  <p>I will appreciate if somebody can give me a hint. What is wrong with the configuration?</p>
  
  <p><strong>The Configuration</strong></p>
  
  <pre><code>@Configuration
  @EnableElasticsearchRepositories(basePackages ="com.company.searchengine.repository")
  public class ElasticSearchConfiguration {
      @Value("${elasticsearch.clustername}")
      private String esClusterName;
  
      @Bean
      public ElasticsearchOperations elasticsearchTemplate() throws IOException {
          return new ElasticsearchTemplate(nodeBuilder().local(true).clusterName
              (esClusterName).node()
              .client());
      }
  }
  </code></pre>
  
  <p><strong>The document</strong></p>
  
  <pre><code>@EqualsAndHashCode(of = "uuid")
  @ToString(exclude = "uuid")
  @NoArgsConstructor(onConstructor = @__({@JsonCreator}))
  @Getter
  @Setter
  @Document(indexName = "profiles", type = "profile", createIndex = false)
  @Setting(settingPath = "/settings/settings.json")
  @Mapping(mappingPath = "/mappings/mappings.json")
  public class IndexedProfile {
      @Id
      @NonNull
      private String uuid;
      @NonNull
      //@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
      private String nickname;
      @NonNull
      //@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
      private String gender;
      //@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
      private String about;
      private GeoPoint location;
      @Field(type = FieldType.Date, format = DateFormat.year_month_day)
      private Date birthdate;
  }
  </code></pre>
  
  <p><strong>The batch job</strong></p>
  
  <pre><code>@Override
  public void write(List&lt;? extends IndexedProfile&gt; items) throws Exception {
      List&lt;IndexQuery&gt; indexQueries = items.stream()
              .map(item -&gt; new IndexQueryBuilder().withObject(item).withId(String.valueOf(item.getUuid())))
              .map(builder -&gt; builder.withType(DOCUMENT_TYPE))
              .map(builder -&gt; builder.withIndexName(INDEX_NAME + runId))
              .map(IndexQueryBuilder::build)
              .collect(Collectors.toList());
  
      this.elasticsearchTemplate.bulkIndex(indexQueries);
  }
  </code></pre>
  
  <p><strong>The settings</strong></p>
  
  <pre><code>{
    "settings": {
         "analysis": {
             "filter": {
                 "nGram_filter": {
                    "type": "nGram",
                     "min_gram": 2,
                     "max_gram": 20,
                     "token_chars": [
                          "letter",
                          "digit",
                          "punctuation",
                          "symbol"
                      ]
              }
          },
          "analyzer": {
               "nGram_analyzer": {
                   "type": "custom",
                   "tokenizer": "whitespace",
                   "filter": [
                        "lowercase",
                        "asciifolding",
                        "nGram_filter"
                   ]
          },
          "whitespace_analyzer": {
              "type": "custom",
              "tokenizer": "whitespace",
              "filter": [
                    "lowercase",
                    "asciifolding"
               ]
           }
        }
      }
    }
  }
  </code></pre>
  
  <p><strong>Mappings</strong></p>
  
  <pre><code>{
    "mappings": {
        "profile": {
            "_all": {
                 "index_analyzer": "nGram_analyzer",
                 "search_analyzer": "whitespace_analyzer"
             },
             "nickname": {
                  "type": "string",
                  "index": "not_analyzed"
             },
             ....
         }
    }
  </code></pre>