title: MultiField mapping using spring-data-elasticsearch annotations
body: <p>I am trying to use spring-data-elasticsearch to set up mappings for a type that is equivalent to the json configuration below and I am running into issues.</p>
  
  <pre><code>{
      "_id" : {
          "type" : "string",
          "path" : "id"
      },
  
      "properties":{
          "addressName":{
              "type":"multi_field",
              "fields":{
                  "addressName":{
                      "type":"string"
                  },
                  "edge":{
                      "analyzer":"edge_search_analyzer",
                      "type":"string"
                  }
              }
          },
          "companyName":{
              "type":"multi_field",
              "fields":{
                  "companyName":{
                      "type":"string"
                  },
                  "edge":{
                      "analyzer":"edge_search_analyzer",
                      "type":"string"
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>Here is the entity class as it stands now:</p>
  
  <pre><code>@Document(indexName = "test", type="address")
  @Setting(settingPath="/config/elasticsearch/test.json") // Used to configure custom analyzer/filter
  public class Address {
  
      @Id
      private Integer id;
  
      @MultiField(
          mainField = @Field(type = FieldType.String),
          otherFields = {
              @NestedField(dotSuffix = "edge", type = FieldType.String, indexAnalyzer = "edge_search_analyzer")
          }
      )        
      private String addressName;
  
      @MultiField(
          mainField = @Field(type = FieldType.String),
          otherFields = {
              @NestedField(dotSuffix = "edge", type = FieldType.String, indexAnalyzer = "edge_search_analyzer")
          }
      )        
      private String companyName;
  
      public Address() {}
  
      public Address(AddressDTO dto) {
          id = dto.getId();
          addressName = dto.getAddressName();
          companyName = dto.getCompanyName();
      }
  
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          Preconditions.checkNotNull(id);
          this.id = id;
      }
  
      public String getAddressName() {
          return addressName;
      }
  
      public void setAddressName(String addressName) {
          this.addressName = addressName;
      }
  
      public String getCompanyName() {
          return companyName;
      }
  
      public void setCompanyName(String companyName) {
          this.companyName = companyName;
      }
  }
  </code></pre>
  
  <p>What I am finding is that this results in a mapping like:</p>
  
  <pre><code>"address" : {
      "properties" : {
          "addressName" : {
              "type" : "string",
              "fields" : {
                  "addressName.edge" : {
                      "type" : "string",
                      "index_analyzer" : "edge_search_analyzer"
                  }
              }
          },
          "companyName" : {
              "type" : "string",
              "fields" : {
                  "companyName.edge" : {
                      "type" : "string",
                      "index_analyzer" : "edge_search_analyzer"
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>Which results in two issues:</p>
  
  <ol>
  <li>Id mapping is not done so Elasticsearch generates the ids</li>
  <li>Searches on the properties with the custom analyzer do not work properly</li>
  </ol>
  
  <p>If I add the following to override the use of the annotations everything works fine:</p>
  
  <pre><code>@Mapping(mappingPath="/config/elasticsearch/address.json")
  </code></pre>
  
  <p>Where "address.json" contains the mapping configuration from the top of this post.</p>
  
  <p>So, can anyone point out where I might be going wrong with what I'm trying to achieve?
  Is is possible using available annotations or am I going to have to stick with json configuration?</p>
  
  <p>Also, is there a "correct" way to setup index-level configuration via spring-data-elasticsearch, or is that not a supported approach?  Currently, I am using the @Setting annotation for this purpose</p>