We have a use case where we want to use certain indices in different cluster so as to improve performance. We are using java based configuration for elasticsearch.
@Log4j
@Configuration
@EnableElasticsearchRepositories(basePackages = ["com.as.core.repositories"])
class ElasticSearchConfig {
@Bean
ElasticsearchOperations elasticsearchTemplate() {
Client client
Settings settings
InetSocketTransportAddress inetSocketTransportAddress = new InetSocketTransportAddress(
Holders.config.grails.elasticsearch.transportClientIP as String,
Holders.config.grails.elasticsearch.transportClientPort as Integer
)
settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "elasticsearch")
.build()
client = new TransportClient(settings)
.addTransportAddress(inetSocketTransportAddress)
return new ElasticsearchTemplate(client)
}
}
- Is there any way so that we can add configurations of a different elastic-search cluster?
- Spring data automatically creates indices in the specified cluster. How is the creation of indices managed in multi cluster application?
What I have googled is there is method addTransportAddresses(inetSocketTransportAddress)
which allow us to add an array of elastic search server addresses.
- But how will we specify multiple cluster names?