@羲凡——只为了更好的活着
Kibana6.0 常用增删改查命令(一)
1.查看基本状态
查看集群健康状态
GET /_cat/health?v
查看集群节点列表
GET /_cat/nodes?v
查看所有的索引
GET /_cat/indices?v
2.基本示例
创建索引并指定分片数量和复本数,且自定义mapping。dynamic是针对现有的索引中没有的字段的控制,“strict”表示报错,“true”表示可以插入,“false”表示忽略
PUT /aaron_index
{
"settings": {
"number_of_shards" : 1 ,
"number_of_replicas" : 0
},
"mappings": {
"aaron_type":{
"dynamic":"strict",
"properties":{
"id":{"type": "integer"},
"name":{"type": "text","analyzer":"standard"},
"birthday":{"type": "date","index":false},
"salary":{"type": "double"},
"hobby":{"type": "text","analyzer":"ik_max_word"}
}
}
}
}
自定义map类型
PUT /aaron_index/aaron_type/_mapping
{
"properties": {
"id":{"type": "integer"},
"name":{"type": "text","analyzer":"standard"},
"birthday":{"type": "date","index":false},
"salary":{"type": "double"},
"hobby":{"type": "text","analyzer":"ik_max_word"}
}
}
查看map类型
GET /_mapping/aaron_type
批量插入数据
POST /aaron_index/aaron_type/_bulk
{ "index": { "_id":1}}
{ "name": "张辽","birthday":"1992-02-27","salary":88888.88,"hobby":"我喜欢跑步,喝酒和打仗"}
{ "index": { "_id": 2}}
{ "name": "曹操","birthday":"1991-01-24","salary":78888.88,"hobby":"我喜欢唱歌,喝酒和打仗"}
{ "index": { "_id": 3}}
{ "name": "夏侯惇","birthday":"1992-03-30","salary":68888.88,"hobby":"我喜欢跑步和打仗"}
{ "index": { "_id": 4}}
{ "name": "夏侯渊","birthday":"1992-03-01","salary":58888.88,"hobby":"我喜欢打仗"}
{ "index": { "_id": 8}}
{ "name": "羲凡","birthday":"1992-03-30","salary":88888.88,"hobby":"我喜欢喝酒"}
查询全量
GET /aaron_index/aaron_type/_search
{
"query": {
"match_all": {}
}
}
查询张辽信息
GET /aaron_index/aaron_type/_search
{
"query": {
"match": {
"name":"张辽"
}
}
}
查询薪资为88888.88的人(数字和日期类型的不能进行分词)
GET /aaron_index/aaron_type/_search?q=salary:88888.88
查询喜欢喝酒的人
GET /aaron_index/aaron_type/_search
{
"query": {
"match": {
"hobby":"喝酒"
}
}
}
删除索引
DELETE /aaron_index
====================================================================
@羲凡——只为了更好的活着
若对博客中有任何问题,欢迎留言交流