- 2025-01-15elasticsearch的RestAPI之操作文档
RestClient操作文档新增文档将DB表中的数据同步到elasticsearch1)查询数据库1.1)数据库查询后的结果是一个Hotel类型的对象1@Data2@TableName("tb_hotel")3publicclassHotel{4@TableId(type=IdType.INPUT)5privateLongid;6privateString
- 2023-09-16ES相关的增删改查操作示例
依赖:<dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId></dependency>修改版本: 第一步:条件准备:首先是配置类:@ConfigurationpublicclassEsConfig{
- 2023-06-23match_all 查询所有【ElasticSearch】
/***match_all查询所有*/@Testpublicvoidtest02()throwsIOException{SearchRequestsearchRequest=newSearchRequest("hotel");SearchSourceBuildersearchSourceBuilder=newSearchSourceBuilder();
- 2023-06-23rang 范围查询【ElasticSearch】
/***rang范围查询*/@Testpublicvoidtest04()throwsIOException{SearchRequestsearchRequest=newSearchRequest();SearchSourceBuildersearchSourceBuilder=newSearchSourceBuilder();searchSourceBuilder
- 2023-06-23term 精确查询【ElasticSearch】
/***term精确查询*/@Testpublicvoidtest03()throwsIOException{SearchRequestsearchRequest=newSearchRequest();SearchSourceBuildersearchSourceBuilder=newSearchSourceBuilder();searchSourceBuilder.
- 2023-06-04Java High Level Rest Client---查询文档
查询文档的基本步骤1)准备Request对象2)准备请求参数3)发起请求4)解析响应示例解析以match_all查询为例代码解读:第一步,创建SearchRequest对象,指定索引库名第二步,利用request.source()构建DSL,DSL中可以包含查询、分页、排序、高亮等query():代表查询条件,利用QueryBuilder
- 2023-06-03Java High Level Rest Client---操作文档
新增文档1)创建Request对象2)准备请求参数,也就是DSL中的JSON文档3)发送请求代码示例:点击查看代码//新增文档@TestpublicvoidaddDoc()throwsException{//根据id查出酒店数据Hotelhotel=iHotelService.getById(36934L);//将酒店