ES常用增删改查小白运维操作
简介
收藏 ES 常用小白运维操作,满足基本需求
基础操作
新增索引
PUT test_index
{
"mappings": {
"properties": {
"name": {
"type": "keyword"
}
}
}
}
查询索引下映射关系
GET test_index/_mapping
添加数据
POST test_index/_doc
{
"name": "张三"
}
查询数据
GET test_index/_doc/SDOgQnYB081yE3IodCn7
更新数据
POST test_index/_update/SDOgQnYB081yE3IodCn7
{
"doc": {
"name": "new_name"
}
}
删除数据
DELETE test_index/_doc/SDOgQnYB081yE3IodCn7
删除索引
DELETE test_index
其他常用操作
获取索引列表
?v 表示携带标题
GET _cat/indices?v
查询所有数据
默认前10条
POST test_index/_search
查询按照指定字段(时间)倒序
update_time 为索引包含字段
POST test_index/_search?sort=update_time:desc
查询指定 id 数据
POST test_index/_doc/SDOgQnYB081yE3IodCn7
精确查询
POST test_index/_search
{
"query": {
"match": {
"name": "张三"
}
}
}
模糊查询
支持 AND OR 操作符,也支持 * 代表任意个字符
POST test_index/_search
{
"query": {
"query_string": {
"default_field": "name",
"query": "*三"
}
}
}