首页 > 其他分享 >基于 JSON 的 DSL 查询 - 实现步骤【ElasticSearch】

基于 JSON 的 DSL 查询 - 实现步骤【ElasticSearch】

时间:2023-06-24 12:33:15浏览次数:33  
标签:searchSourceBuilder searchRequest DSL 查询 JSON ElasticSearch 搜索 todo

ES DSL查询实现

        //todo 2.准备Request - 搜索哪个索引库
        SearchRequest searchRequest = new SearchRequest("hotel");
//todo 4.所有的搜索条件封装对象 searchSourceBuilder SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//**************** 条件封装的位置 *******************
//************************************************
//todo 3.准备DSL - 添加搜索条件 searchRequest.source(searchSourceBuilder);
//todo 1.发送请求 - 搜索方法 SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
//todo 5.抽取返回值数据 SearchHits searchHits = searchResponse.getHits();

 

标签:searchSourceBuilder,searchRequest,DSL,查询,JSON,ElasticSearch,搜索,todo
From: https://www.cnblogs.com/Rover20230226/p/17500919.html

相关文章

  • client【ElasticSearch】
    1、client @BeanpublicRestHighLevelClientclient(){//client对象就是操作ES的对象RestHighLevelClientclient=newRestHighLevelClient(RestClient.builder(HttpHost.create("http://192.168.221.......
  • ElasticSearch依赖(7.12.1)【ElasticSearch】
    <!--ES依赖--><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId><!--忽略掉冲突的依赖-->......
  • RestClient查询【ElasticSearch】
    packagecn.itcast.hotel;importcn.itcast.hotel.pojo.HotelDoc;importcom.alibaba.fastjson.JSON;importorg.apache.http.HttpHost;importorg.elasticsearch.action.search.SearchRequest;importorg.elasticsearch.action.search.SearchResponse;importorg.elas......
  • match_all 查询所有【ElasticSearch】
    /***match_all查询所有*/@Testpublicvoidtest02()throwsIOException{SearchRequestsearchRequest=newSearchRequest("hotel");SearchSourceBuildersearchSourceBuilder=newSearchSourceBuilder();......
  • rang 范围查询【ElasticSearch】
    /***rang范围查询*/@Testpublicvoidtest04()throwsIOException{SearchRequestsearchRequest=newSearchRequest();SearchSourceBuildersearchSourceBuilder=newSearchSourceBuilder();searchSourceBuilder......
  • term 精确查询【ElasticSearch】
    /***term精确查询*/@Testpublicvoidtest03()throwsIOException{SearchRequestsearchRequest=newSearchRequest();SearchSourceBuildersearchSourceBuilder=newSearchSourceBuilder();searchSourceBuilder.......
  • 遍历Json
    privatevoidSetShpFcSaveC5s(ShpFcSavemodel){if(string.IsNullOrWhiteSpace(model.C5)==false){JsonDocumentdocument=JsonDocument.Parse(model.C5);foreach(JsonElementjsonElementindocument.RootElement.EnumerateArray())......
  • .NET 6 中 System.Text.Json 的新特性
    1支持忽略循环引用在.NET6之前,如果 System.Text.Json 检测到循环引用,就会抛出 JsonException 异常。在.NET6中,你可以忽略它们。Categorydotnet=new(){Name=".NET6",};CategorysystemTextJson=new(){Name="System.Text.Json",Parent=......
  • match查询【ElasticSearch】
    /***match分词再查询*/@Testpublicvoidtest01()throwsIOException{//todo2.搜索条件封装SearchRequestsearchRequest=newSearchRequest("hotel");//todo4.所有搜索条件封装到searchSourceBuilder对象S......
  • Elasticsearch核心应用场景-日志优化实践
    1.背景日志领域是Elasticsearch(ES)最重要也是规模最大的应用场景之一。这得益于ES有高性能倒排索引、灵活的schema、易用的分布式架构,支持高吞吐写入、高性能查询,同时有强大的数据治理生态、端到端的完整解决方案。但原生ES在高吞吐写入、低成本存储、高性能查询等方面还有......