Elasticsearch(ES)

1.Elasticsearch简介

1.1

分布式全文搜索引擎

1.2

倒排序索引:关键字--id--数据(传统索引:id--数据)。

创建文档:建立数据关系(每一条数据)。

使用文档:输入关键字找到文档。

2.启动ES

启动成功

 3.添加分词器ik,重新启动ES

4.利用postman创建索引(json格式与ES的版本有关 ES6.5.4)

JSON格式化高亮工具 - 在线JSON校验格式化工具(K JSON)

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

5.创建文档

创建文档的时候ES一直报错,不能有type类型。

{
    "name":"小花",
    "description":"我是一个听话的孩子"
}

post  http://localhost:9200/students/_doc  使用系统生成的id

post  http://localhost:9200/students/_doc/4  使用指定id,不存在创建,存在更新(版本递增)

post  http://localhost:9200/students/_create/4  使用指定id

6.查询文档

get    http://localhost:9200/students/_doc/4  查询单个文档

get    http://localhost:9200/students/_search  查询全部文档

get    http://localhost:9200/students/_search?q=decription:'"听话"  查询全部文档

7.删除文档

delete    http://localhost:9200/students/_doc/4

8.修改文档

8.1全量修改

put    http://localhost:9200/students/_doc/2

{
    "name":"小明",
    "description":"我是一个听话的孩子"
}

8.2部分修改

 post    http://localhost:9200/students/_doc/2/_update?pretty   ES版本6.5.4.

 post    http://localhost:9200/students/_update/2       ES版本 7.16.2

{
    "doc":{
        "name":"哎呦"
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值