基于kibana的Dev Tools控制板上es常用查询语句
1、集群相关
--- 查询集群健康状态 GET _cluster/health --- 查询所有节点 GET _cat/nodes --- 查询索引及分片的分布 GET _cat/shards --- 查询所有插件 GET _cat/plugins
2、索引相关查询
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | --- 查询所有索引及容量 GET _cat/indices --- 查询索引映射结构 GET my_index/_mapping --- 查询所有索引映射结构 GET _all --- 查询所有的相同前缀索引 GET my-*/_search --- 查询所有索引模板 GET _template --- 查询具体索引模板 GET _template/my_template |
3.索引的操作
1、写入索引模板
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | PUT _template/my_template { "template" : "my-*" , "order" : 0, "settings" : { "number_of_shards" : 10, "number_of_replicas" : 0 }, "mappings" : { "default" : { "_all" : { "enabled" : false }, "properties" : { "name" : { "type" : "text" }, "age" : { "type" : "long" } } } } } |
2、创建索引映射结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | PUT my_index { "mappings" : { "doc" : { "properties" : { "name" : { "type" : "text" }, "blob" : { "type" : "binary" } } } } } |
3、写入索引
1 2 3 4 5 | PUT my_index/doc/1 { "name" : "Some binary blob" , "blob" : "U29tZSBiaW5hcnkgYmxvYg==" } |
4、删除索引
1 | DELETE my-index |
5、DSL query查询
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | a、查询所有 GET _search { "query" : { "match_all" : {} } } b、查询单个索引 的 固定属性 --- 精确匹配 GET _search { "query" : { "term" : { "name" : "you" } } } --- 模糊匹配 GET _search { "query" : { "match" : { "name" : "you" } } } --- 范围查找 GET _search { "query" : { "range" : { "age" :{ "gte" : 15 , "lte" : 25 } } } } c、功能性查询 --- 过滤 GET my_index/_search { "query" : { "bool" : { "filter" : { "term" :{ "age" :1095} } } } } --- 或 or GET my - test / _search { "query" : { "bool" : { "should" : [{ "term" : { "name" : "you" } }, { "match" : { "age" : 20 } }] } } } --- 与 AND GET my-test/_search { "query" : { "bool" : { "must" : [{ "match" : { "name" : "you" } },{ "range" :{ "age" :{ "from" : 10 , "to" : 20 } } }] } } } ---必须 = GET my_index/_search { "query" : { "bool" : { "must" : { "range" : { "age" : { "from" : 10, "to" : 20 } } } } } } --- 必须不 not GET my_index/_search { "query" : { "bool" : { "must_not" : { "term" : { "name" : "you" } } } } } d、复合查找 GET my_index/_search { "query" : { "bool" : { "should" : [{ "match" : { "age" : 40 } }, { "match" : { "age" : 20 } }], "filter" : { "match" :{ "name" : "you" } } } } } e、索引迁移 --- 场景 从A索引 复制到B索引 POST _reindex { "source" : { "index" : "my_index" }, "dest" : { "index" : "new_my_index" } } f、基于查询的删除 POST test-index/_delete_by_query { "query" :{ "term" : { "cameraId" : "00000000002" } } } --- 查询 GET test-index/_search { "query" :{ "term" : { "cameraId" : "00000000002" } } } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构