I am trying elastic search in spring boot application and I would like to debug on queries executed by ElasticsearchRepository.
tried
logging.level.org.elasticsearch.index.search.slowlog.query=INFO
spring.data.elasticsearch.properties.index.search.slowlog.threshold.query.info=1ms
but I didn't see the query print in log
The ElasticsearchTemplate class is deprecated as it uses the TransportClient to access Elasticsearch, which itself is deprecated since Elasticsearch version 7.
Spring Data for Elasticsearch is part of the umbrella Spring Data project which aims to provide a familiar and consistent Spring-based programming model for for new datastores while retaining store-specific features and capabilities.
ElasticSearch is well known as a search engine, also working well as document based NoSQL. Spring Data ElasticSearch adds basic Reactive support.
Using Springboot 2.2.6, and RestHighLevelClient
, the following worked:
logging.level.org.springframework.data.elasticsearch.client.WIRE : trace
This is also documented in springboot-data-elasticsearch
However, you need to pay attention to initialize your RestHighLevelClient
bean in the same way stated in the documentation. I.e, using the ClientConfiguration
builder.
At first I created the bean as new RestHighLevelClient()
and it didn't work.
Example:
@Bean(destroyMethod = "close")
public RestHighLevelClient restClient() {
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo(esHost +":" + esPort).usingSsl()
.build();
RestHighLevelClient client = RestClients.create(clientConfiguration).rest();
return client;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With