ElasticSearch——常用命令
集群相关
--查询集群健康状态
GET _cluster/health --查询所有节点
GET _cat/nodes --查询索引及分片的分布
GET _cat/shards --查询指定索引分片的分布
GET _cat/shards/order_stpprdinf_2019-12?v --查询所有插件
GET _cat/plugins
索引相关查询
--查询所有索引及容量
GET _cat/indices --查询索引映射结构
GET my_index/_mapping --查询所有索引映射结构
GET _all --查询所有的相同前缀索引
GET my-*/_search --查询所有索引模板
GET _template --查询具体索引模板
GET _template/my_template
索引相关操作
1、创建索引模板
# 创建模板
PUT _template/test_hot_cold_template
{
"index_patterns": "test_*",
"settings": {
"number_of_shards" : ,
"index.number_of_replicas":
},
"mappings": {
"order": {
"dynamic": false,
"properties": {
"id": {"type": "long"},
"name": {"type": "keyword"}
}
}
},
"aliases": {
"test": {}
}
} # 根据模板创建索引并写入数据
POST test_hot_cold---/order
{
"id":,
"name":"cwx"
} # 删除模板
DELETE _template/order_stpprdinf_template
2、直接创建索引
PUT my_index
{
"mappings": {
"doc": {
"properties": {
"name": {
"type": "text"
},
"blob": {
"type": "binary"
}
}
}
}
}
-- 增加字段
put my_index/_mapping/doc
{
"properties": {
"cwxtest": {"type": "keyword"}
}
} -- 数据冷备份
PUT _snapshot/my_backup # my_backup 备份的名称
{
"type": "order",
"settings": {
"location": "/mount/backups/my_backup"
}
}
3、写入索引
PUT my_index/doc/
{
"name": "Some binary blob",
"blob": "U29tZSBiaW5hcnkgYmxvYg=="
}
4、删除索引
DELETE my-index
5、修改索引setting
PUT /test_hot_cold---/_settings
{
"settings": {
"index.routing.allocation.require.hotwarm_type": "cold"
}
}
DSL query查询
--1.查询所有
GET _search
{
"query": {
"match_all": {}
}
} --2.查询单个索引 的 固定属性
--精确匹配
GET _search
{
"query": {
"term": { "name" : "you" }
}
} --模糊匹配
GET _search
{
"query": {
"match": { "name" : "you" }
}
}
--范围查找
GET _search
{
"query": {
"range": {
"age":{ "gte" : , "lte" : }
}
}
}
GET indexName/_search
{
"query": {
"wildcard":{"relateId":"*672499460503*"}
}
}
--3.功能性查询
--过滤
GET my_index/_search
{
"query": {
"bool": {
"filter": {
"term":{"age":}
}
}
}
} --或 or
GET my - test / _search
{
"query": {
"bool": {
"should": [{
"term": {
"name": "you"
}
}, {
"match": {
"age":
}
}]
}
}
} --与 AND
GET my-test/_search
{
"query": {
"bool": {
"must" : [{
"match" : {
"name" : "you"
}
},{
"range":{
"age":{
"from" : , "to" :
}
}
}]
}
}
} --必须 =
GET my_index/_search
{
"query": {
"bool": {
"must" : {
"range" : {
"age" : { "from" : , "to" : }
}
}
}
}
} --必须不 not
GET my_index/_search
{
"query": {
"bool": {
"must_not" : {
"term" : {
"name" : "you"
}
}
}
}
} --复合查找
GET my_index/_search
{
"query": {
"bool": {
"should": [{
"match": {
"age":
}
},
{
"match": {
"age":
}
}],
"filter": {
"match":{
"name":"you"
}
}
}
}
} --4.索引迁移
--场景 从A索引 复制到B索引
POST _reindex
{
"source": {
"index": "my_index"
},
"dest": {
"index": "new_my_index"
}
} --5.基于查询的删除
POST test-index/_delete_by_query
{
"query":{
"term": {
"cameraId":""
}
} } --查询
GET test-index/_search
{
"query":{
"term": {
"cameraId":""
}
}
}
按时间范围查询:
GET order_stpprdinf_2019-/_search
{
"size":,
"query":{
"range":{
"order_time":{
"gte":"2019-12-11T00:00:00+08:00",
"lte":"2019-12-11T23:59:59+08:00"
}
}
}
}
按条件删除:
GET order_stpprdinf_2019-/_delete_by_query?conflicts=proceed
{
"query":{
"range":{
"order_time":{
"gte":"2019-12-11T00:00:00+08:00",
"lte":"2019-12-11T23:59:59+08:00"
}
}
}
}
可在kibana的Dev Tools控制板上执行以上命令:

参考链接:https://blog.csdn.net/ailice001/article/details/79541816
ElasticSearch——常用命令的更多相关文章
- elasticsearch常用命令
elasticsearch的rest访问格式: curl -X<REST Verb> <Node>:<Port>/<Index>/<Type> ...
- elasticsearch 常用命令
#查看集群状态 curl -XGET "http://localhost:9200/_cluster/health?pretty" #查看所有的快照 curl -XGET &quo ...
- 实战ELK(2) ElasticSearch 常用命令
1.Cluster Health 集群状态 curl 'localhost:9200/_cat/health?v' yellow代表分片副本确实,因为我们现在只有一台机器. curl 'localho ...
- elasticsearch 常用命令(一)
索引 搜索 mapping 分词器 1.创建索引 http://192.168.65.131:9200/smartom_index?pretty 2.查看索引: http://192.168.65.1 ...
- elasticsearch 常用命令 一直红色 重启不稳定 不停的宕机
persistent (重启后设置也会存在) or transient (整个集群重启后会消失的设置). 查看集群状态和每个indices状态.搜索到red的,没用就删除 GET /_cluster/ ...
- elasticsearch常用命令备注
1.检查集群健康状态 curl 'localhost:9200/_cat/health?v' 2.检查节点健康状态 curl 'localhost:9200/_cat/nodes?v' 3.新增一条索 ...
- elasticsearch(四) 之 elasticsearch常用的一些集群命令
目录 elasticsearch常用的一些集群命令 查看集群健康状态 查看集群的节点列表 查看所有的索引 删除索引 查询索引的某个文档内容 更新文档 删除文档 自动创建索引 定时删除索引 elasti ...
- elasticsearch 索引清理脚本及常用命令
elastic索引日志清理不及时,很容易产生磁盘紧张,官网给出curl -k -XDELETE可以清理不需要的索引日志. 清理脚本 #!/bin/bash #Author: 648403020@qq. ...
- Docker安装和常用命令
Docker安装 Docker的安装可以参考 https://docs.docker.com/ 下面的 Get Docker / Docker CE / Linux, 需要关注的主要是CentOS和U ...
随机推荐
- Ubuntu系统---安装QQ
使用Ubuntu很不方便,如果有什么消息的话,还要回到windows中查看.预想在Ubuntu上直接安装一个QQ,有网友说使用WebQQ发现老是掉线,于是这里安装QQ国际版. 首先,下载安装包. 这里 ...
- BZOJ2208 [Jsoi2010]连通数[缩点/Floyd传递闭包+bitset优化]
显然并不能直接dfs,因为$m$会非常大,复杂度就是$O(mn)$: 这题有三种做法,都用到了bitset的优化.第二种算是一个意外的收获,之前没想到竟然还有这种神仙操作.. 方法一:缩点+DAG上b ...
- Qt 程序自动重启的实现
正常退出调用exit() 或quit()就行,想要自已重启可按下面代码: void XXX:onRestart() { //类中调用 qApp->exit(); } 主main函数中处理 int ...
- httpClient请求响应延迟
客户端可以先向服务器端发送一个请求,如果服务器端返回的是状态码100,那么客户端就可以继续把请求体的数据发送给服务器端.这样在某些情况下可以减少网络开销. 再看看HttpClient里面对100-Co ...
- 11 git第二部分(未完成)
https://www.cnblogs.com/shangchunhong/p/9444335.html
- [Spring Boot] Set Context path for application in application.properties
If you were using Microservice with Spring Boot to build different REST API endpoints, context path ...
- Python JSONⅢ
JSON 函数 encode Python encode() 函数用于将 Python 对象编码成 JSON 字符串. 语法 实例 以下实例将数组编码为 JSON 格式数据: 以上代码执行结果为: d ...
- winform中的Windows Media Player播放器设置
namespace WindowsMediaPlayer{ public partial class Form1 : Form { Form2 form2;//声明from2窗体 public For ...
- 【转载】全网最!详!细!tarjan算法讲解。
转自http://www.cnblogs.com/uncle-lu/p/5876729.html [转载]全网最!详!细!tarjan算法讲解.(已改正一些奥妙重重的小错误^_^) 全网最详细tarj ...
- 《30天自制操作系统》学习笔记--Mac下工具的使用
现在来介绍官网上下的工具怎么用首先是官网地址,书上有个注释上有:hrb.osask.jp 翻译成中文大概是这个样子滴. 上面有两个文件可以下载,一个是工具,一个是工具的源代码,很好的学习资料 下面把工 ...