简体   繁体   English

在 Elastic NativeSearchQuery 中添加大小

[英]Add Size in Elastic NativeSearchQuery

        final QueryBuilder contentTagQuery = QueryBuilders.boolQuery()
                .filter( QueryBuilders.termQuery("tenantId" , "en"));

        SearchHits<Content> searchHits =
                elasticsearchOperations.search(
                        new NativeSearchQuery(contentTagQuery), Content.class,
                        IndexCoordinates.of("index"));

How can I add size in this query, as I only need the first result.如何在此查询中添加大小,因为我只需要第一个结果。

You can set this on the Query instance:您可以在Query实例上进行设置:

NativeSearchQuery query = new NativeSearchQuery(contentTagQuery);
query.setMaxResults(1);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 NativeSearchQuery 从 Elasticsearch 查询数据时出现问题 - Issue with querying data with NativeSearchQuery from Elasticsearch 在 Elastic 原生查询中添加查询超时 - springboot - Add query timeout in Elastic native query - springboot 使用 Amazon Linux 2 为使用 AWS Elastic Beanstalk 托管的 Java Spring Boot 应用程序添加 SSL 证书 - Add SSL certificate for Java Spring Boot App hosted using AWS Elastic Beanstalk using Amazon Linux 2 如何在 Tomcat AWS Elastic beanstalk (Spring Boot Application) 中修改或添加新的 Nginx 配置 - How to modify or add new Nginx configuration in Tomcat AWS Elastic beanstalk (Spring Boot Application) 当我在 aws 弹性 beantalk 中部署 Spring Boot 项目时,如何压缩 Spring Boot 中的 MultipartFie[] 大小? - How can i compress the MultipartFie[] size in spring boot when i deploy the spring boot project in aws elastic beanstalk.? 无法在 AWS Elastic Beanstalk Java SE 平台上设置 JVM 堆大小 - Not able to set JVM heap size on AWS Elastic Beanstalk Java SE Platform 为 findAllByTypeAndCreatedAtAfter() mongodb 方法添加最大尺寸限制和方向 - Add maximum size limit and direction to findAllByTypeAndCreatedAtAfter() mongodb method 获取ThreadPoolTask​​Executor的队列大小并在Spring Boot中添加到队列 - Get queue size of ThreadPoolTaskExecutor and add to queue in Spring boot Spring Boot +弹性搜索 - Spring Boot + Elastic Search Elastic Search Should 子句 - Elastic Search Should clause
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM