How to do source filtering in ElasticSearch in spring boot project?

徘徊边缘 提交于 2020-07-23 06:41:07

问题


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:


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.



来源:https://stackoverflow.com/questions/62695368/how-to-do-source-filtering-in-elasticsearch-in-spring-boot-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!