【Elasticsearch】Kibana操作Es的常用语句

查询所有es里的索引
GET _cat/indices
查询
# 查询
GET index名/_search
条件匹配
GET index名/_search
{
  "query": {
    "match": {
      "id":123
    }
  }
}
多字段查询:
GET index名/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "name": "张三"
          }
        },
        {
          "match": {
            "age": "22"
          }
        }
      ]
    }
  }
}

GET index名/_search
{
  "query": {
    "bool": {
      "must": {
        "match":{
          "id":"123"
        }
      },
      "filter": {
        "range": {
          "addTime": {
            "gte": "2022-02-22 00:00:00",
            "lte": "2022-02-24 23:59:59"
          }
        }
      }
    }
   
  }
}
条件删除
POST / index名/_delete_by_query?slices=auto&conflicts=proceed&wait_for_completion=false
{
  "query":{
    "bool":{
      "must": [
        {
   		 "range":{
    		"addTime":{
    			"from":"2023-07-01 00:00:00",
    			"to":"2023-07-03 23:59:59"
    			}
   			}
        }
      ]
    }
  }
}
计数
GET index名/_count
sql 查询
GET _sql?format=json
{
  "query": "SELECT * FROM index名"
}
设置最大可显示数据量
PUT _all/_settings
{
  "index.max_result_window":1000000
}
重命名索引(拷贝)
POST _reindex
{
  "source": {
    "index": "源索引"
  },
  "dest": {
    "index": "新索引"
  }
}
清理索引缓存
POST index名/_cache/clear
增加字段
PUT /index名/_mapping
{
  "properties": {
    "字段名": {
      "type": "keyword" //类型
    }
  }
}
条件删除数据
POST /index/_delete_by_query?slices=auto&conflicts=proceed&wait_for_completion=false
{
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "time": {
              "from": "2023-09-27 11:00:00",
              "to": "2023-09-27 23:59:59"
            }
          }
        }
      ]
    }
  }
}
往新索引中写入旧索引条件范围内的数据,修改某个字段值
POST _reindex?slices=6&refresh
{
  "source": {
    "index": "旧索引",
    "query": {
      "bool": {
        "must": [
          {
            "range": {
              "time": {
                "from": "2023-09-01 00:00:00",
                "to": "2023-09-06 23:59:59"
              }
            }
          }
        ]
      }
    }
  },
  "dest": {
    "index": "新索引"
  },
  "script": {
    "source": "ctx._id='ABC'+ctx._id;ctx._source.字段名='ABC'+ctx._source.字段名"
  }
}
查看节点
GET _cat/nodes?v
查看执行中的任务
GET _tasks
结束某个任务
POST /_tasks/31rgRai2TiGhh5wEH4ngug:49752268/_cancel
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值