1、查看安装了哪些插件
GET http://192.168.80.131:9200/_cat/plugins

2、查询有哪些索引
GET http://192.168.80.131:9200/_cat/indices

3、创建索引
- 不带映射创建索引
PUT http://192.168.80.131:9200/tb_hero

- 带映射创建索引
PUT http://192.168.80.131:9200/tb_hero
{
"mappings": {
"properties":{
"id":{
"type":"long"
},
"name":{
"type":"keyword"
},
"tech":{
"type":"text",
"analyzer":"ik_max_word",
"search_analyzer":"ik_smart"
},
"age":{
"type":"integer"
},
"update_time":{
"type":"date"
}
}
}
}

4、创建映射
PUT http://192.168.80.131:9200/tb_hero/_mapping
{
"properties":{
"id":{
"type":"long"
},
"name":{
"type":"keyword"
},
"tech":{
"type":"text",
"analyzer":"ik_max_word",
"search_analyzer":"ik_smart"
},
"age":{
"type":"integer"
},
"update_time":{
"type":"date"
}
}
}

5、查看索引
GET http://192.168.80.131:9200/tb_hero

6、删除索引
DELETE http://192.168.80.131:9200/tb_hero

7、测试分词
- 所有语言的默认使用的就是这个标准分词器
# 方法1:
GET http://192.168.80.131:9200/_analyze
# 方法2:
POST http://192.168.80.131:9200/_analyze
{
"analyzer":"standard",
"text":"武松打虎"
}

- IK分词器
1)、ik_smart
http://192.168.80.131:9200/_analyze?pretty=true
{
"analyzer":"ik_smart",
"text":"武松打虎"
}

2)、ik_max_word
GET http://192.168.80.131:9200/_analyze?pretty=true
{
"analyzer":"ik_max_word",
"text":"武松打虎"
}

8、添加文档
POST http://192.168.80.131:9200/tb_hero/_doc/1
{
"id": 1,
"name": "武松",
"tech": "景阳冈打虎",
"age": 66,
"update_time": "2020-12-11"
}

9、根据ID查询文档
GET http://192.168.80.131:9200/tb_hero/_doc/1

10、全匹配查询
GET http://192.168.80.131:9200/tb_hero/_search

11、单文档全量修改
PUT http://192.168.80.131:9200/tb_hero/_doc/1
{
"id": 1,
"name": "武松",
"tech": "景阳冈打虎,醉打蒋门神",
"age": 38,
"update_time": "2023-09-03"
}

11、单文档局部修改
POST http://192.168.80.131:9200/tb_hero/_update/1
{
"doc": {
"age": 33
}
}

12、根据ID删除文档
DELETE http://192.168.80.131:9200/tb_hero/_doc/1

13、条件查询
根据英雄的技能查询
GET http://192.168.80.131:9200/tb_hero/_search
{
"query":{
"match":{
"tech": "草料"
}
}
}
