use of org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate in project spring-data-elasticsearch by spring-projects.
the class AbstractElasticsearchConfiguration method elasticsearchOperations.
/**
* Creates {@link ElasticsearchOperations}.
*
* @return never {@literal null}.
*/
@Bean(name = { "elasticsearchOperations", "elasticsearchTemplate" })
public ElasticsearchOperations elasticsearchOperations(ElasticsearchConverter elasticsearchConverter, RestHighLevelClient elasticsearchClient) {
ElasticsearchRestTemplate template = new ElasticsearchRestTemplate(elasticsearchClient, elasticsearchConverter);
template.setRefreshPolicy(refreshPolicy());
return template;
}
use of org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate in project spring-data-elasticsearch by spring-projects.
the class ElasticsearchRestTemplateConfiguration method elasticsearchOperations.
@Override
public ElasticsearchOperations elasticsearchOperations(ElasticsearchConverter elasticsearchConverter, RestHighLevelClient elasticsearchClient) {
ElasticsearchRestTemplate template = new ElasticsearchRestTemplate(elasticsearchClient, elasticsearchConverter) {
@Override
public <T> T execute(ClientCallback<T> callback) {
try {
return super.execute(callback);
} catch (DataAccessResourceFailureException e) {
try {
Thread.sleep(1_000);
} catch (InterruptedException ignored) {
}
return super.execute(callback);
}
}
};
template.setRefreshPolicy(refreshPolicy());
return template;
}
Aggregations