title: Can I use multiple elastic search hosts in Spring Bean configuration for multiple elastic search indexes
body: <p>I have a Java API to insert documents to three elastic indexes and it is working. I want to change one index's host in API. Normally, EsConfig file and ElasticSearchTemplate code is ;</p>
  
  <pre><code>public class EsConfig {
      @Value("${elasticsearch.host}")
      private String EsHost;
     @Value("${elasticsearch.port}")
     private int EsPort;
     @Value("${elasticsearch.clustername}")
     private String EsClusterName;
  
     @Bean
     public Client client() throws Exception {
        Settings settings = Settings.builder()
              .put("cluster.name", EsClusterName)
              //.put("index.max_result_window", 4000000)
              .build();
  
        TransportClient client = new PreBuiltTransportClient(settings)
              .addTransportAddress(new 
        TransportAddress(InetAddress.getByName(EsHost), EsPort));
        return client;
       }
  
       @Bean
       public ElasticsearchTemplate elasticsearchTemplate() throws Exception {
            ElasticsearchTemplate elasticsearchTemplate = new ElasticsearchTemplate(client());
            return elasticsearchTemplate;
        }
  </code></pre>
  
  <p>}</p>
  
  <p>I want to configure this structure to use two hosts together. Is it possible in this structure or should I completely change and remove singleton bean structure?</p>