首页 > 其他分享 >term 精确查询【ElasticSearch】

term 精确查询【ElasticSearch】

时间:2023-06-23 11:34:13浏览次数:33  
标签:term hotelDoc searchSourceBuilder searchHits searchRequest 查询 ElasticSearch

    /**
     * term 精确查询
     */
    @Test
    public void test03() throws IOException {
        SearchRequest searchRequest = new SearchRequest();

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(QueryBuilders.termQuery("brand","万怡"));
        searchRequest.source(searchSourceBuilder);
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);

        SearchHits searchHits = searchResponse.getHits();

        System.out.println("总条数:" + searchHits.getTotalHits().value);
        SearchHit[] hits = searchHits.getHits();
        for (SearchHit hit : hits) {
            HotelDoc hotelDoc = JSON.parseObject(hit.getSourceAsString(), HotelDoc.class);
            System.out.println("数据:" + hotelDoc);
        }
    }

 

标签:term,hotelDoc,searchSourceBuilder,searchHits,searchRequest,查询,ElasticSearch
From: https://www.cnblogs.com/Rover20230226/p/17498909.html

相关文章

  • match查询【ElasticSearch】
    /***match分词再查询*/@Testpublicvoidtest01()throwsIOException{//todo2.搜索条件封装SearchRequestsearchRequest=newSearchRequest("hotel");//todo4.所有搜索条件封装到searchSourceBuilder对象S......
  • Elasticsearch核心应用场景-日志优化实践
    1.背景日志领域是Elasticsearch(ES)最重要也是规模最大的应用场景之一。这得益于ES有高性能倒排索引、灵活的schema、易用的分布式架构,支持高吞吐写入、高性能查询,同时有强大的数据治理生态、端到端的完整解决方案。但原生ES在高吞吐写入、低成本存储、高性能查询等方面还有......
  • Elasticsearch核心应用场景-日志优化实践
    1.背景日志领域是Elasticsearch(ES)最重要也是规模最大的应用场景之一。这得益于ES有高性能倒排索引、灵活的schema、易用的分布式架构,支持高吞吐写入、高性能查询,同时有强大的数据治理生态、端到端的完整解决方案。但原生ES在高吞吐写入、低成本存储、高性能查询等方面还有......
  • es 查询
    packagecom.heima.search.service.impl;importcom.alibaba.fastjson.JSON;importcom.heima.model.common.dtos.ResponseResult;importcom.heima.model.common.enums.AppHttpCodeEnum;importcom.heima.model.search.dtos.UserSearchDto;importcom.heima.model.user.pojos......
  • es多字段查询:queryString
      https://blog.csdn.net/zl18603543572/article/details/129629817 ......
  • ElasticSearch的安装与启动
    1.ElasticSearch介绍1.1.什么是ESElasticSearch是一个基于Lucene的搜索服务器。它提供了一个基于RESTfulweb接口的分布式全文搜索引擎。ElasticSearch是用Java语言开发的,并作为Apache许可条款下的开放源码发布,是一种流行的企业级搜索引擎。ElasticSearch用于云计算中,能够达到实......
  • linux下根据端口号查询对应进程
    1、命令lsof,以查找占用端口80为例,用法如下:[root@localhostnginx]#lsof-i:80--命令[root@localhostnginx]#--返回什么都没有表示:没有进程占用80端口[root@localhostsbin]#lsof-i:80COMMANDPIDUSERFDTYPEDEVICESIZE/OFFNODENAMEnginx8246root6uI......
  • pgsql获取日期段_PostgreSQL时间段查询
    1.今日select*from"表名"whereto_date("时间字段"::text,'yyyy-mm-dd')=current_date2.昨日select*from"表名"whereto_date("时间字段"::text,'yyyy-mm-dd')=current_date-13.最近半个月select*from"表名"......
  • elasticsearch-head 的搭建
    elasticsearch-head全部是js和html5写的,elasticsearch全部都是http的接口,这样,只需要简单地本地配置一个虚拟站点,就可以搭建 elasticsearch-head. 下面是简单地搭建步骤.Github工具确保有个Github客户端工具下载Github的代码,我使用的是:http://windows.github.com/ Clone......
  • MySQL给查询出的数据增加序号
    前言我们都知道,在Oracle中,可以使用ROW_NUMBER()OVER()函数给查询的结果加序号。不了解请点击:ROW_NUMBER()OVER()MySQL几乎模拟了Oracle,SQLServer等商业数据库的大部分功能,函数。MySQL8.0版本以后才会有这个函数,之前版本是没有的MySQL给查出的数据加序号的方法一种......