ES常用操作命令

这篇具有很好参考价值的文章主要介绍了ES常用操作命令。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1集群操作命令

集群运行状态:用于通过附加'health'关键字来获取集群运行状况的状态。

GET /_cluster/health

集群状态:通过附加'state'关键字URL来获取有关集群的状态信息。状态信息包含版本,主节点,其他节点,路由表,元数据和块。

GET /_cluster/state

集群统计:通过使用'stats'关键字来帮助检索有关群集的统计信息。返回分片号,存储大小,内存使用率,节点数,角色,操作系统和文件系统。

GET /_cluster/stats

节点统计:用于检索集群中另外一个节点的统计信息。节点统计信息与集群几乎相同。

GET /_nodes/stats

节点热线程:检索有关群集中每个节点上的当前热线程的信息。

GET /_nodes/hot_threads

2.索引操作命令

创建索引:当用户将JSON对象传递给任何索引时,可以自动创建索引,也可以在此之前创建索引。要创建索引,需要发送带有设置,映射和别名的PUT请求,或者仅发送不带正文的简单请求。

PUT index_name
{
  "settings" : {
      "index" : {
         "number_of_shards" : 3,  //分片数
         "number_of_replicas" : 2  //副本数
      }
   }
}

删除索引:需要传递带有该特定索引名称的删除请求即可。_all或*可删除所有索引。

DELETE /index_name

获取索引:返回索引相关的信息

GET index_name

索引设置:在请求末尾附加_settings关键字即可获取索引设置。

GET /index_name/_settings

索引统计:提取有关特定索引的统计信息。

GET /index_name/_stats

冲洗(flush):索引的刷新过程可确保当前仅保留在事务日志中的所有数据也将永久保留在Lucene中。这减少了恢复时间,因为在打开Lucene索引之后,不需要从事务日志中重新索引数据。

GET/index_name/_flush

3文档操作命令

创建文档:PUT index_name/_doc/5

查询文档:GET index_name/_doc/5

修改文档:POST index_name/_update/5

删除文档:DELETE index_name/_doc/5

4查询操作命令

匹配所有查询:这是最基本的查询;它返回所有内容。

POST /index_name/_search
{
   "query":{
      "match_all":{}
   }
}

匹配查询:此查询将文本或短语与一个或多个字段的值匹配。

POST /index_name*/_search
{
   "query":{
      "match" : {
         "rating":"4.5"
      }
   }
}

多重对比查询:此查询将一个或多个字段匹配的文本或短语匹配。

POST / index_name */_search
{
   "query":{
      "multi_match" : {
         "query": "paprola",
         "fields": [ "city", "state" ]
      }
   }
}

字符串查询:该查询使用查询解析器和query_string关键字。

POST /index_name*/_search
{
   "query":{
      "query_string":{
         "query":"beautiful"
      }
   }
}

词级查询(精确值查询):主要处理结构化数据,例如数字,日期和枚举。(terms多值查找)

POST /index_name*/_search
{
   "query":{
      "term":{"zip":"176115"}
   }
}

范围查询:该查询用于查找具有给定值范围之间的值的对象。为此,我们需要使用运算符,

gte −大于等于

gt −大于

lte −小于等于

lt −小于

例如:查询rating字段数值大于等于3.5的结果

POST /index_name*/_search
{
   "query":{
      "range":{
         "rating":{
            "gte":3.5
         }
      }
   }
}

复合查询:这些查询是不同查询的集合,这些查询通过使用布尔运算符(例如和/或,或不)或针对不同的索引或具有函数调用等彼此合并。

POST /index_name/_search
{
   "query": {
      "bool" : {
         "must" : {
            "term" : { "state" : "UP" }
         },
         "filter": {
            "term" : { "fees" : "2200" }
         },
         "minimum_should_match" : 1,
         "boost" : 1.0
      }
   }
}

地理查询:查询处理地理位置。这些查询有助于找出学校或任何其他地理位置附近的地理对象。需要使用地理位置数据类型。

PUT /geo_example
{
   "mappings": {
      "properties": {
         "location": {
            "type": "geo_shape"
         }
      }
   }
}

布尔过滤器:

{
   "bool" : {
      "must" :     [ ],
      "should" :   [ ],
      "must_not" : [ ],
      "filter":    [ ]
   }
}

must ——所有的语句都 必须(must)匹配,与 AND 等价。

must_not ——所有的语句都不能(must not)匹配,与 NOT 等价。

should ——至少有一个语句要匹配,与 OR 等价。

filter——必须匹配,运行在非评分&过滤模式。

当我们需要多个过滤器时,只须将它们置入 bool 过滤器的不同部分即可。

查询某个字段是否存在:

GET /my_index/posts/_search
{
    "query" : {
        "constant_score" : {
            "filter" : {
                "exists" : { "field" : "tags" }
            }
        }
    }
}

前缀检索:匹配包含的前缀字符

GET /_search
{ "query": {
  "prefix" : { "user" : "ki" }
  }
}

通配符检索:匹配具有匹配通配符表达式( (not analyzed )的字段的文档。 支持的通配符:

1)*,它匹配任何字符序列(包括空字符序列);

2)?,它匹配任何单个字符。

为了防止非常慢的通配符查询,通配符不能以任何一个通配符*或?开头。

GET /_search
{
    "query": {
        "wildcard" : { "user" : "ki*y" }
    }
}

正则表达式检索:正则表达式查询允许使用正则表达式术语查询。*查询比较慢,通常需要使用一个长的前缀。

GET /_search
{
  "query": {
      "regexp":{
          "name.first": "s.*y"
          }
      }
}

模糊检索:模糊查询查找在模糊度中指定的最大编辑距离内的所有可能的匹配项,然后检查术语字典,以找出在索引中实际存在待检索的关键词。

GET /_search
{
  "query": {
      "fuzzy" : { "user" : "ki" }
  }

类型检索:检索索引中,type为指定类型的全部信息。

GET /my_index/_search
{
  "query": {
      "type" : {
          "value" : "xext"
          }
      }
}

IDs检索:返回指定id的全部信息。

GET /my_index/_search
{
  "query": {
      "ids" : {
          "type" : "text",
              "values" : ["2", "4", "100"]
          }
      }
}

排序查询:

get /index_good/_search
{
    "query":{
        "term":{
            "title":"oppo手机"  //只有title=“oppo手机”的文档数据才会被查询到
        }
    },
    "sort":[      // 查询结果根据【order by price desc,name asc】进行排序
        {"price":{"order":"desc"}},
        {"name":{"name":"asc"}}
    ]
}

分页查询:

get /index_good/_search
{
    "query":{
        "term":{
            "title":"oppo手机"    // 只有title=“oppo手机”的文档数据才会被查询到
        }
    },
    "sort":[      //查询结果根据【order by price desc,name asc】进行排序
        {"price":{"order":"desc"}},
        {"name":{"name":"asc"}}
    ],
    "from":5,         //从第5条数据开始取10条(es中的数据从第0条开始)
    "size":10
}

Mget批量查询:进行查询的时候,如果一次性查询多条数据的话,采用批量操作的api,尽可能减少网络开销次数,可以将性能大幅度提升。

GET _mget
{
    "docs": [
        {
            "_index": "example",
            "_type": "docs",
            "_id": "1"
        }
        {
            "_index": "example_test",
            "_type": "docs",
            "_id": "1"
        },
    ]
}

bulk批量操作:es提供的一种批量增删改的操作。

create:如果文档不存在就创建,但如果文档存在就返回错误

index:如果文档不存在就创建,如果文档存在就更新

update:更新一个文档,如果文档不存在就返回错误

delete:删除一个文档,如果要删除的文档id不存在,就返回错误

索引及映射结构准备:

PUT example

PUT example/docs/_mapping
{
  "properties": {
    "id": {"type": "long"},
    "name": {"type": "text"},
    "counter": {"type": "integer"},
    "tags": {"type": "text"}
  }
}

批量插入:

POST example/docs/_bulk

{"index": {"_id": 1}}
{"id":1, "name": "admin", "counter":"10", "tags":["red", "black"]}

{"index": {"_id": 2}}
{"id":2, "name": "张三", "counter":"20", "tags":["green", "purple"]}

{"index": {"_id": 3}}
{"id":3, "name": "李四", "counter":"30", "tags":["red", "blue"]}

{"index": {"_id": 4}}
{"id":4, "name": "tom", "counter":"40", "tags":["orange"]}

批量更新:

POST example/docs/_bulk

{"update": {"_id": 1}}
{"doc": {"id":1, "name": "admin-02", "counter":"11"}}

{"update": {"_id": 2}}
{"script":{"lang":"painless","source":"ctx._source.counter += params.num","params": {"num":2}}}

{"update":{"_id": 3}}
{"doc": {"name": "test3333name", "counter": 999}}

{"update":{"_id": 4}}
{"doc": {"name": "test444name", "counter": 888},  "doc_as_upsert" : true}

批量删除:

POST example/docs/_bulk

{"delete": {"_id": 1}}
{"delete": {"_id": 2}}
{"delete": {"_id": 3}}
{"delete": {"_id": 4}}

混合操作:

POST _bulk

{ "index" : { "_index" : "example", "_type" : "docs", "_id" : "1" } }
{ "name" : "value11111" }
{ "delete" : { "_index" : "example", "_type" : "docs", "_id" : "2" } }
{ "create" : { "_index" : "example", "_type" : "docs", "_id" : "3" } }
{ "tags" : "value333" }
{ "update" : {"_id" : "4", "_type" : "docs", "_index" : "example"} }
{ "doc" : {"name" : "混合444"}

msearch批量查询:批量查询多个索引中的多个条件(减少IO次数)。

POST _msearch

{"index":"movies"
{"query":{"match_all":{}},"from":0,"size":3}
{"index":"users"}
{"query":{"match_phrase":{"name.keyword":"nie"}}}
{"index":"books"}
{"query":{"match":{"bookName":"中国通史"}}}

query:查询上下文,会有一个相关性匹配度的分数。

fiter:过滤查询,必须满足的条件,没有匹配度分数。只回答是或不是,查询效率更高。

查询和过滤条件的合并:search API中只能包含 query 语句,所以我们需要用 filtered 来同时包含 "query" 和 "filter" 子句:

GET /_search
{
    "query": {
        "filtered": {
            "query":  { "match": { "email": "business opportunity" }},
            "filter": { "term": { "folder": "inbox" }}
        }
    }
}

常用API
1、curl -sXGET  "http://localhost:9200?pretty"       查看ES版本信息
2、curl -sXGET  "http://localhost:9200/_cluster/health?pretty"    检查集群状况
3、curl -sXGET "http://localhost:9200/_cat/indices?v"    查看集群内的所有索引
4、curl -sXGET "http://localhost:9200/_cat/indices/skyeye-tcpflow-2020.05.25?v"   查看指定索引,注:skyeye-tcpflow-2020.05.25为要查看的索引名
5、curl -sXGET "http://localhost:9200/_cat/nodes?v" |sort -k9   查看集群中的所有节点信息,当集群内节点较多时(有些业务100多个节点)使用sort进行排序,查看哪些节点不在集群内
6、curl -sXGET "http://localhost:9200/_cat/master?v"   查看master节点信息,当需要查看master节点日志时,需要先确定master是哪个节点
7、curl -sXGET "http://localhost:9200/_cat/allocation?v"  查看集群内分片的部分情况,查看分片分布是否均衡
8、curl -sXGET "http://localhost:9200/_cat/thread_pool/bulk,search?v"   查看集群bulk(入库)和search(查询)线程池的情况,当查询卡慢时可以查看
9、curl -sXGET "http://localhost:9200/_cat/pending_tasks?v"   查看集群内的排队的任务有哪些
10、curl -sXGET "http://localhost:9200/_cat/tasks?v"      查看集群内当前执行的任务有哪些
11、curl -sXGET "http://localhost:9200/_cat/nodes?h=name,segments.memory&v"   查看集群内segments的占用内存的情况
12、curl -sXGET "http://localhost:9200/_cluster/allocation/explain?pretty"    当执行_clster/health发现集群内有不能分片的分片(unassigned_shards>0)时,执行该命令,该命令返回很长,可以输出到一个文件中,传给二线查看分析原因
13、curl -sXGET "http://localhost:9200/_cluster/settings?pretty"              查看集群的设置,比如:磁盘平衡,分片平衡等设置
14、curl -sXGET "http://localhost:9200/skyeye-tcpflow-2020.05.25/_settings?pretty"   查看某个索引的设置,比如:索引的total_shards_per_node,number_of_replicas等设置,注:skyeye-tcpflow-2020.05.25为要查看的索引名,需更换实际需要查看的对应索引名
15、curl -XPOST "http://localhost:9200/*2020.03*/_close"          关闭索引,批量关闭2020年3月的索引,也可以只关闭指定的某一个索引,写上对应的索引名即可,注:关闭索引并不是删除索引,一线人员可以操作
16、curl -XPOST "http://localhost:9200/*2020.03*/_open"           打开索引,批量打开2020年3月的索引,也可以只打开指定的某一个索引,写上对应的索引名即可,
    通常索引关闭再打开,叫reopen,一般使用循环的方式将一批yellow的索引进行reopen操作如:
    curl -sXGET "http://localhost:9200/_cat/indices" | grep -w yellow | awk '{print $3}'|while read line;do curl -XPOST "http://localhost:9200/$line/_close";curl -XPOST "http://localhost:9200/$line/_open";done
17、curl -XDELETE "http://localhost:9200/$index"   删除指定的索引,注:删除操作直接会将磁盘中的数据删除,一定确认之后没有问题再执行
18、curl -XPUT "http://localhost:9200/$index"      创建索引,注:$index为要创建的索引名称,
19、curl -sXGET "http://localhost:9200/_nodes/hot_threads?pretty" | less     该api返回当前集群线程在处理什么任务。在进行问题定位的时候会用到。只要了解即可,不需要去分析输出的内容,
20、curl -sXGET "http://localhost:9200/_nodes?pretty" | grep logs            查看集群配置的日志和数据的存放路径
21、curl -sXGET localhost:9200/_cat/recovery?ignore_unavailable=true | grep -v done 查看集群分片恢复情况
22、curl -sXGET "http://localhost:9200/_cat/nodes?h=name,port,segments.memory,segments.index_writer_memory,fielddata.memory_size,query_cache.memory_size,request_cache.memory_size&v" 节点内存占用情况
23、ES别名
    curl  -sXGET localhost:9200/_cat/aliases?v  查看别名
    curl -XPOST 'http://localhost:9200/_aliases'-d '{"actions" : [{ "add" : { "index" : "test1","alias" : "alias1" } }]}' 添加别名
    curl -XPOST 'http://localhost:9200/_aliases'-d '{"actions" : [{ "remove" : { "index" : "test1","alias" : "alias1" } }]}' 移除别名
24、merge
    curl -sXPOST "$http://localhost:9200/$index/_forcemerge?max_num_segments=$segment_count
25、缓存清理
    curl -sXPOST localhost:9200/_cache/clear?pretty
26、禁止计算迁移分片空间
    curl -sXPUT localhost:9200/_cluster/settings?master_timeout=10m -d '{"transient":{"cluster.routing.allocation.disk.include_relocations":"false"}}
27、设置最小master数
    curl -XPUT "http://localhost:9200/_cluster/settings" -d '{"persistent" : {"discovery.zen.minimum_master_nodes" : 2}}'
27、查询分片数调整
    curl -u es:es -XPUT 'http://localhost:9200/_cluster/settings' -H 'Content-Type: application/json' -d' { "persistent" : {"action.search.shard_count.limit" : "2000"}

ES动态参数修改
1、curl -sXPUT "http://localhost:9200/*2018.06.13*/_settings" -d '{"index.routing.allocation.total_shards_per_node":2}'           修改指定索引的total_shards_per_node,如果想修改集群内所有索引,可以将索引名称用_all参数替换
2、curl -sXPUT "http://localhost:9200/*2017.09.19/_settings" -d '{"index.refresh_interval":"120s"}'                               修改索引的refresh时间
3、curl -XPUT "http://localhost:9200/$index/_settings" -d '{"settings":{"index.unassigned.node_left.delayed_timeout":"120h"}}'    修改由于节点下线,重新分片的时机。
4、#修改每个节点并发recovery的副本数量,如果机器资源充足,修改较大的值有利于提高集群恢复的进度。recovery主要受限于网络带宽。
curl -sXPUT "http://localhost:9200/_cluster/settings" -d '{"transient":{"cluster.routing.allocation.node_concurrent_recoveries":"40"}}' 副本恢复并发数
curl -sXPUT "http://localhost:9200/_cluster/settings" -d '{"transient":{"cluster.routing.allocation.node_initial_primaries_recoveries":"20"}}' 主分片恢复并发数
5、#禁用启用集群的查询服务。在某些时候,由于大量的查询占用了很多资源,导致集群恢复严重缓慢,禁用查询可以提高恢复速速。警告:禁用后所有查询无法完成,需要在相关人认可的情况下执行该操作。
curl -sXPUT "http://localhost:9200/_cluster/settings" -d '{"transient":{"cluster.search.enabled":"false"}}'
curl -sXPUT "http://localhost:9200/_cluster/settings" -d '{"transient":{"cluster.search.enabled":"true"}}'
6、#禁止分片划分到某个节点或者某个机器,出现磁盘故障或者下线机器时会用到,执行后,分片会从对应的节点和机器移走,根据数据量大小,可能需要一定的时间才能移完
curl -sXPUT "http://localhost:9200/_cluster/settings" -d '{"persistent":{"cluster.routing.allocation.exclude._name":"es.10.208.41.16.7"}}'
curl -sXPUT "http://localhost:9200/_cluster/settings" -d '{"persistent":{"cluster.routing.allocation.exclude._ip":"10.203.159.107"}}'
7、curl -sXPUT "http://localhost:9200/*2018.06.13*/_settings" -d '{"index.number_of_replicas":0}'    修改索引的副本数量
8、curl  -sXPUT "localhost:9200/_cluster/settings" -d '{"transient":{"cluster.routing.allocation.awareness.attributes": null}}' 允许多个分片能够分配在同一机器上
9、curl -XPUT 'http://localhost:9200/_cluster/settings' -d '{"transient":{"logger.org.elasticsearch.index.engine": "TRACE"}}' 设置日志级别
10、curl -sXPUT localhost:9200/_cluster/settings?master_timeout=10m -d ' { "persistent": { "action.destructive_requires_name": "false" }}' 通配符使用
11、curl  -sXPUT http://localhost:9200/_cluster/settings -d' {"persistent" :{ "indices.recovery.max_bytes_per_sec" :"30mb" }}' 设置分片迁移速度
12、索引只读
 curl -sXPUT localhost:9200/noah_aaa_20210109/_settings?pretty -d'{"index.blocks.read_only":false}'
 curl -sXPUT localhost:9200/noah_aaa_20210109/_settings?pretty -d'{"index.blocks.read_only_allow_delete":null}'
13、规定分片划分到某个节点或者机器
    curl -sXPUT "http://$host/$index/_settings" -H "Content-Type: application/json" -d '{"settings":{"index.routing.allocation.require._name":"'$node_name'"}
    curl -sXPUT "http://$host/$index/_settings" -H "Content-Type: application/json" -d '{"settings":{"index.routing.allocation.require._ip":"'$node_ip'"}
13、分片均衡
    curl   -sXPUT "http://localhost:9200/_cluster/settings" -d '{"transient":{"cluster.routing.allocation.balance.disk.enabled":"false"}}'
    curl   -sXPUT "http://localhost:9200/_cluster/settings" -d '{"transient":{"cluster.routing.rebalance.enable":"none"}}'
14、均衡迁移的分片数
    curl -sXPUT "http://localhost:9200/_cluster/settings" -d '{"transient":{"cluster.routing.allocation.cluster_concurrent_rebalance":"20"}}'

查找索引:
curl -X GET "localhost:9200/_cat/indices?v&h=index,store.size" |grep tool

查找模板:
curl -sXGET localhost:9200/_cat/templates?v | grep index
curl -XDELETE localhost:9200/_template/index_name
sh /opt/work/search/es/bin/index.sh template.update
sh /opt/work/search/es/bin/index.sh -i skyeye-dns-2023.11.28 create

常用命令
1、删除僵尸索引
grep "can not be imported as a dangling index" /data*/es/logs/es*/es.log | sed 's/.*\[\[\(.*\)\/\(.*\)\]\].*/\2/g' | sort | uniq |while read line; do echo $lind; find /data*/es/nodes/0/indices -name ${line} | xargs rm -rf; done >/dev/null 2>&1 &
2、task管理
    curl -sXGET "localhost:9200/_tasks?actions=*search&detailed&pretty"
    curl -sXPOST "localhost:9200/_tasks/_cancel?nodes=nodeId&actions=*reindex"
3、分配过期分片
    curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -H 'Content-Type: application/json' -d'
{
  "commands": [
    {
      "allocate_stale_primary": {
        "index": "index_name-2017.12.21",
        "shard": 1,
        "node": "es.$ip.3",
        "accept_data_loss": true
      }
    }
  ]
}
'
4、分空分片
curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -H 'Content-Type: application/json' -d'
{
  "commands": [
    {
      "allocate_empty_primary": {
        "index": "index_name-2017.12.21",
        "shard": 1,
        "node": "es.$ip.3",
        "accept_data_loss": true
      }
    }
  ]
}
'
批量分空
curl  -u es_admin:%36.Hadoop*  -sXGET localhost:9200/_cat/shards/ | grep UNASSIGNED | grep -w p | while read line;do id=$(($RANDOM%1));index=`echo $line | awk '{print$1}'`;shard=`echo $line | awk '{print$2}'`; curl -u es_admin:%36.Hadoop* -XPOST 'localhost:9200/_cluster/reroute?pretty' -H 'Content-Type: application/json' -d'{"commands": [{ "allocate_empty_primary": {"index": "'$index'","shard":"'$shard'","node":"es.机器名称或ip.'$id'","accept_data_loss":true}}]}'; done > /dev/null 2>&1 &
5、translog 文件损坏修复
 bin/elasticsearch-translog truncate -d /data$i/es/nodes/0/indices/$index_dir/$shard_number/translog/

查看每个索引是否均衡:
curl -sXGET -ues_admin:%36.Hadoop* "http://localhost:9200/_cat/indices/*2022.08.28?h=index,ip" | sort | uniq | awk '{print $1}' | while read line;do echo $line;curl -sXGET -ues_admin:%36.Hadoop*  "http://localhost:9200/_cat/shards/*2022.08.28?h=index,ip" | grep $line | awk '{print $2}' |sort |uniq -c;done
设置当天索引保证磁盘平衡 (105为节点总数):
curl -sXGET   -ues_admin:%36.Hadoop*  "http://localhost:9200/_cat/indices/*2022.08.28" | while read line;do index=`echo $line | awk '{print $3}'`;shard_num=`curl     -sXGET  -ues_admin:%36.Hadoop*  "http://localhost:9200/_cat/shards/$index" | wc -l`;total_shards_per_node=$(($shard_num / 105));total_shards_per_node=$(($total_shards_per_node + 1));curl -sXPUT  -ues_admin:%36.Hadoop*  "http://localhost:9200/$index/_settings" -d     '{"index.routing.allocation.total_shards_per_node":'$total_shards_per_node'}';done

查看集群write、search线程池状态
curl -ues_admin:%36.Hadoop* -sXGET "http://localhost:9200/_cat/thread_pool/?v&h=id,name,active,rejected,queue,size,type&pretty&s=type"

查看red索引:curl -sXGET localhost:9200/_cat/indices?health=red
开启行为分析索引:脚本
关闭:curl -sXGET localhost:9200/_cat/indices?health=red | awk '{print $3}' | while read index; do echo $index; curl -sXPOST localhost:9200/$index/_close; done
删除:curl -sXGET localhost:9200/_cat/indices?health=red | awk '{print $3}' | while read index; do echo $index; curl -sXDELETE localhost:9200/$index; done
重建:cd /opt/work/search/es/template/skyeye/;for index in `ll *.tmpl | awk '{print $9}' | cut -d '.' -f1`; do echo $index; sh /data/index.sh -i $index create; done

统计每个索引分片平均大小:
curl -ues_admin:%36.Hadoop* -sXGET "http://localhost:9200/_cat/indices/*2022.08.28?h=index,pri,pri.store.size&bytes=gb" | while read line;do size=`echo $line | awk '{print $3}'`;p=`echo $line | awk '{print $2}'`;index=`echo $line | awk '{print $1}'`;echo "$index $(($size/$p))";done | sort -nk2 | column –t
统计索引前三天的数据索引大小:
curl -ues_admin:%36.Hadoop* -sXGET localhost:9200/_cat/indices/index_name-2023.08.09,index_name-2023.08.08,index_name-2023.08.07

2 ES常用命令
1.    curl –sXGET localhost:9200/_cluster/health?pretty
2.    curl –sXGET localhost:9200/_cat/shards?v
3.    curl –sXGET localhost:9200/_cat/nodes?v
4.    curl –sXGET localhost:9200/_nodes/stats?pretty
5.    curl –sXGET localhost:9200/_cluster/stats?pretty
6.    curl –sXGET localhost:9200/_cat/allocations?v
7.    curl –sXGET localhost:9200/_cat/pending_tasks?v
8.    curl –sXGET localhost:9200/_cat/master?v
9.    curl –sXGET localhost:9200/_cat/recovery?v
10.查看线程池    curl –sXGET localhost:9200/_cat/thread_pool?v
11.    curl –sXGET localhost:9200/_cat/segments?v
12.    curl –XPOST localhost:9200/skyeye-dns-2023.06.07/_close?pretty
13.    curl –XPOST localhost:9200/skyeye-dns-2023.06.07/_open?pretty
14.    curl –XDELETE localhost:9200/skyeye-dns-2023.06.07?pretty文章来源地址https://www.toymoban.com/news/detail-846207.html

到了这里,关于ES常用操作命令的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • ES常用查询命令

    一、基本命令 1、获取所有_cat命令 2、获取es集群服务健康状态 epoch: 时间戳的 Unix 时间戳格式,表示快照生成的时间。 timestamp: 可读性更强的时间戳格式,表示快照生成的时间(08:06:34)。 cluster: Elasticsearch 集群的名称,这里是 \\\"es-cluster\\\"。 status: 集群的健康状态,这里是 \\\"y

    2024年02月04日
    浏览(37)
  • ES 集群常用排查命令

    说明:集群使用非默认端口9200,使用的是7116端口举例 一、常用命令 #1.集群健康状态 二、案例分析 2.1集群变红 症状:集群变红 分析:通过Allocation Explain API 发现创建索引失败,因为无法找到标记了相应box type的节点 解决:删除索引,集群变绿,重新创建索引,并且指定正确

    2024年02月09日
    浏览(30)
  • ES常用命令与常用查询(1)

    查看集群状态 创建索引 查看所有索引 查看索引信息 删除索引 2.1 查询所有 match_all 使用match_all,默认只会返回10条数据 返回指定条数 size 不能无限大,如果过大会出现异常 1、查询结果的窗口太大,from + size的结果必须小于或等于10000,而当前查询结果的窗 口为20000。 2、可以

    2024年02月06日
    浏览(43)
  • Elasticsearch(ES)常用命令整理

    在前几篇文章大家主要进行Elasticsearch的入门学习,了解了它的基本概念和工作原理,也学习到Elasticsearch集群的角色和主要职责。接下来,本文着重介绍了Elasticsearch的常用基础命令。 1.1 获取所有_cat命令 命令:curl -XGET localhost:9200/_cat 以上的命令中,你也可以 后面加一个v,让

    2023年04月08日
    浏览(74)
  • es查看集群状态常用命令

    1.查看集群数据的正确率 active_shards_percent_as_number这个值如果低于100说明集群数据正确性存在问题,集群状态为yellow或者red都会使这个值低于100 2.查看集群索引的状态

    2024年02月11日
    浏览(33)
  • Java操作es插入数据后,立即查询没结果解决办法

    原因:ES默认不执行刷新操作,需要手动设置参数才能在更新文档后立即刷新。 从以下源码中可以看出刷新策略有三种: NONE(“false”)、IMMEDIATE(“true”)、WAIT_UNTIL(“wait_for”) 添加位置如下: 官网地址:es批量操作官方文档 注:默认是不进行刷新的,因此需要手动添加进行刷

    2024年02月12日
    浏览(36)
  • es集群问题排查、常用命令、参数解析

    一、常用命令 二、案例分析 2.1集群变红 症状:集群变红 分析:通过Allocation Explain API 发现创建索引失败,因为无法找到标记了相应box type的节点 解决:删除索引,集群变绿,重新创建索引,并且指定正确的routing box type,索引创建成功集群保持绿色状态 2.2集群变黄 症状:集

    2024年02月12日
    浏览(24)
  • curl 命令操作ES

    curl其实是一种用URL语法,它是一种传输数据工具,是通过命令来进行工作的。Curl在很多的操作系统中被使用,其中包括Unix、和Linux,除此之外,也有DOS和Win64等的版本。curl 命令是利用 url 在命令行下进行工作的传输工具,它支持包括 file、ftp、ftps、http、https、imap、imaps、l

    2024年02月06日
    浏览(24)
  • es的语法操作命令

    ES提供了一个highlight属性,和query同级别的 fragment_size :指定高亮数据展示多少个字符回来; pre_tag:指定前缀标签,如 font color=“red” post_tags:指定后缀标签,如 /font field:指定那个字段为高亮字段 聚合:相当于mysql 中的sum(求和) text:会分词,不支持聚合 keyword:不会分

    2023年04月08日
    浏览(27)
  • linux操作es 命令

    1.检查ES节点是否正常启动 curl http://192.168.6.16:9200 正常状态: 非正常状态: 1确保服务是不是正常启动了,端口用的是哪个 2防火墙是否关闭或者端口是否开放 3你的curl命令是否有问题,curl命令可能导致服务无法访问,可以尝试重启服务后,在外部浏览器访问URL地址即可。不

    2024年02月12日
    浏览(31)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包