【问题标题】:How to do source filtering in ElasticSearch in spring boot project?spring boot项目中如何在ElasticSearch中进行源过滤?
【发布时间】:2020-10-22 23:53:05
【问题描述】:

如何使用 spring-data-elasticsearch 使弹性搜索查询仅返回 Spring Boot 项目中的特定字段?我们正在使用最新版本的 spring boot 和 elastic search。 使用 elasticsearchtemplate 或 elasticsearchresttemplate 哪个模板,它们与 java 高级别的 rest 客户端有何不同?

【问题讨论】:

    标签: spring-boot elasticsearch spring-data spring-data-elasticsearch


    【解决方案1】:

    如果您使用ElasticsearchOperations 接口(@98​​7654323@ 和ElasticsearchRestTemplate 实现),用于定义要执行的查询的 Query 接口有一个方法 addSourceFilter ,您可以在其中添加一个 FetchSourceFilter 定义字段要从 Elasticsearch 中检索,其他字段将为空。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-27
    • 1970-01-01
    • 2019-04-12
    • 2020-05-17
    • 2018-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多