springboot整合ES和IK分词器及使用ES文档的基本操作 high level cilent

ES应用场景:全文分布式搜索引擎
倒排索引===>创建文档===>使用文档

ES安装包:
链接:https://pan.baidu.com/s/1oO56WOc0s-Me6wfobL4CEw
提取码:71zz

下载IK分词器,解压至ES的plugins目录下
链接:https://pan.baidu.com/s/1USCUEBoxxqjGqdkdmtA2dw
提取码:t1qm

运行
elasticsearch.bat

浏览器输入http://localhost:9200/,出现以下字符则运行成功

{
  "name" : "LAPTOP-II2DNBO4",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "jSUK96vzS1SRenRXK33o2A",
  "version" : {
    "number" : "7.16.2",
    "build_flavor" : "default",
    "build_type" : "zip",
    "build_hash" : "2b937c44140b6559905130a8650c64dbd0879cfb",
    "build_date" : "2021-12-18T19:42:46.604893745Z",
    "build_snapshot" : false,
    "lucene_version" : "8.10.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline : "You Know, for Search"

通过 postman 访问ES(一直发送请求需要重启ES)
1.创建指定索引 写方法体

{
    "mappings":{
        "properties":{
            "id":{
                "type":"keyword"  
            },
            "name":{
                "type":"text",     
                "analyzer":"ik_max_word",  
                "copy_to":"all"  
            },
            "description":{
                "type":"text", 
                "analyzer":"ik_max_word",
                "copy_to":"all" 
            },
            "type":{
                "type":"keyword" 
            },
            "all":{
                "type":"text", 
                "analyzer":"ik_max_word
            }
        }
    }
}

在这里插入图片描述
2.查询指定索引
在这里插入图片描述

创建ES文档 POST请求:

http://localhost:9200/books/_doc   <!--生成随机id-->
http://localhost:9200/books/_doc/1   <!--生成指定id-->
http://localhost:9200/books/_create/2    <!--生成指定id-->

在这里插入图片描述
查询ES文档 GET请求:

http://localhost:9200/books/_doc/3  <!--查询id为3的ES文档-->
http://localhost:9200/books/_search  <!--查询所有ES文档-->
http://localhost:9200/books/_search?q=name:springboot  <!--查询包含 指定内容的ES文档-->

删除ES文档 DELETE请求

`http://localhost:9200/books/_doc/3`  <!--删除id为3的ES文档-->

修改ES文档 PUT请求 内容是全覆盖
第一种方式:
在这里插入图片描述
第二种方式:
在这里插入图片描述
springboot 整合 ES high level cilent
添加相关依赖:

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值