title: How to interact with elastic search Alias using Spring data
body: <p>Hi I am using elastic search Spring data. Domain structure of my project keeps on changing.So I have to drop the index in order to change the mapping every time. To overcome this problem, I am using Aliases.
  I created an Alias using:</p>
  
  <pre><code>elasticsearchTemplate.createIndex(Test.class);
  elasticsearchTemplate.putMapping(Test.class);
  
      String aliasName = "test-alias";
      AliasQuery aliasQuery = new AliasBuilder()
              .withIndexName("test")
              .withAliasName(aliasName).build();
  
      elasticsearchTemplate.addAlias(aliasQuery);
  </code></pre>
  
  <p>I have a test class:</p>
  
  <pre><code>import org.springframework.data.annotation.Id
  import org.springframework.data.elasticsearch.annotations.Document
  import org.springframework.data.elasticsearch.annotations.Field
  import org.springframework.data.elasticsearch.annotations.FieldIndex
  import org.springframework.data.elasticsearch.annotations.FieldType
  import org.springframework.data.elasticsearch.annotations.Setting
  
  
  @Document(indexName = "test", type = "test")
  @Setting(settingPath = 'elasticSearchSettings/analyzer.json')
  class Test  extends BaseEntity{
  
  @Id
  @Field(type = FieldType.String, index = FieldIndex.not_analyzed)
  String id
  
  @Field(type = FieldType.String, index = FieldIndex.analyzed, indexAnalyzer = "generic_analyzer", searchAnalyzer = "generic_analyzer")
  String firstName
  
  
  
  }
  </code></pre>
  
  <p>TestRepository Class:</p>
  
  <pre><code>package com.as.core.repositories
  
  import com.as.core.entities.Test
  import org.springframework.data.elasticsearch.repository.ElasticsearchRepository
  
  interface TestRepository extends ElasticsearchRepository&lt;Test, String&gt;          
  {
  
  
  }
  </code></pre>
  
  <p>My question is how can I read from alias instead of the index itself?
  Does write operation also takes place on alias.
  I have looked at following link:
  <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/index-aliases.html#index-aliases" rel="noreferrer">https://www.elastic.co/guide/en/elasticsearch/guide/current/index-aliases.html#index-aliases</a>
  It says that we will have to interact the alias instead of the actual index.How to achieve this using Elasticsearch Spring data Java API.</p>