how to make Elastic search query return only particular fields in spring boot project using spring-data-elasticsearch? we are using most recent versions of spring boot and elastic search. Which template to use elasticsearchtemplate or elasticsearchresttemplate and how both of them are different from java high level rest client?
1 Answers
0
votes
If you are using the ElasticsearchOperations
interface (which ElasticsearchTemplate
and ElasticsearchRestTemplate
implement), the Query interface that is used to define the query to execute has a method addSourceFilter where you can add a FetchSourceFilter which defines the fields to be retrieved from Elasticsearch, the other fields will be null.