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 ...
随机推荐
- Maven编译指定(跳过)Module
今天在项目里新添加了一个Module, 但是在jenkins编译的时候会将这个Module也编译, 问题是这个Module根本不需要编译而且巨慢. 因此我只想编译指定模块 ModuleA以及它依赖的必 ...
- 【2019 CCPC 秦皇岛】J - MUV LUV EXTRA
原题: 题意: 给你两个整数a和b,再给你一个正小数,整数部分忽略不计,只考虑小数部分的循环节,对于所有可能的循环节,令其长度为l,在小数部分循环出现的长度为p,最后一个循环节允许不完整,但是缺少的部 ...
- SpringMVC问题整理
JSP页面无法获取ModelAndView里的值 自己搭的项目突然EL表达式取不到值了 不管是用 ${msg} 还是用JSTL的<c:out value="${msg}"/& ...
- Mysql数据库备份—-通过LVM快照实现备份还原
一.实验环境 一台测试机:A(172.18.30.1) 操作系统:Centos7 操作对象数据库版本:mariadb-10.2 二.实现目的 从A机器(172.18.30.1)简单搭建数据库,创建测试 ...
- IE的F12开发人员工具不显示 转载自:http://blog.csdn.net/longyulu/article/details/8749705
IE的F12开发人员工具不显示问题: 按下F12之后,开发人员工具在桌面上看不到,但是任务栏里有显示.将鼠标放在任务栏的开发人员工具上,出现一片透明的区域,选中之后却出不来.将鼠标移动到开发人员工具的 ...
- 区间第K小——可持久化线段树模板
概念 可持久化线段树又叫主席树,之所以叫主席树是因为这东西是fotile主席创建出来的. 可持久化数据结构思想,就是保留整个操作的历史,即,对一个线段树进行操作之后,保留访问操作前的线段树的能力. 最 ...
- BZOJ 2927: [Poi1999]多边形之战 (博弈)
题意 有一个凸多边形,顶点编号逆时针从0到n-1.现在这个n边形被剖分成n-2个三角形,给出这n-2个三角形的顶点,保证这是用n-3条不交叉的对角线划分出来的.现在第一个三角形是黑色,其他都是白色.两 ...
- am335x system upgrade usb wifi rtl8188eus(十九)
1 Scope of Document This document describes how to port rtl8188eus driver to linux 4.14.y desig ...
- 【csp模拟赛1】不服来战 (challenge.cpp)
[题目描述] 最近小 Z 和他的朋友都迷上了一款手机游戏:不服来战. 游戏的设定十分简单,在游戏开始时,会给出一排共 N 个灯,有的灯是开着 的有的是关着的,每个灯都有一个分数.而玩家可以进行任意次操 ...
- 关于centos6版本执行程序报错:libc.so.6: version GLIBC_2.14 not found的解决
执行后程序报错: libc.so.6: version GLIBC_2.14 not found 这种情况是因为当前服务器glibc的版本比较低造成的(不出意外是glibc_2.12是最高版本): 1 ...