Elasticsearch6.4专题之杂记:常用命令

1、list all index

curl -X GET "localhost:9200/_cat/indices?v"

2、get Mapping

GET /twitter/_mapping/tweet

3、delete index

curl -XDELETE "http://127.0.0.1:9200/indexName"

4、getTaskInfo

curl -XGET "http://127.0.0.1:9200/_tasks?actions=*reindex"

5、reindex

curl -XPOST "http://127.0.0.1:9200/_reindex?wait_for_completion=false" -H 'Content-Type: application/json' -d'
{
  "source": {
    "index": "apievent_20190403",
    "type": "apievent_20190403"
  },
  "dest": {
    "index": "apievent_20190403v181",
    "type": "_doc"
  }
}'

6、getTaskinfo

curl -XGET "http://127.0.0.1:9200/_tasks/fTzoT6pVTYaOt28A9ABMMA:11470959"

7、cancel task

curl -X POST "localhost:9200/_tasks/oTUltX4IQMOUUVeiohTt8A:12345/_cancel"

8、task group

curl -X GET "localhost:9200/_tasks?group_by=parents"

9、添加别名

curl -X PUT "localhost:9200/logs_201305/_alias/2013"

10、删除别名

curl -X DELETE "localhost:9200/logs_20162801/_alias/current_day"

11、创建索引setting和mapping

1]
curl -X PUT "localhost:9200/twitter" -H 'Content-Type: application/json' -d'
{
    "settings" : {
        "index" : {
            "number_of_shards" : 3, 
            "number_of_replicas" : 2 
        }
    }
}'
2]
curl -X PUT "localhost:9200/test" -H 'Content-Type: application/json' -d'
{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "_doc" : {
            "properties" : {
                "field1" : { "type" : "text" }
            }
        }
    }
}'

12、from-size分页

curl -XGET "http://127.0.0.1:9200/apievent_20190403/_search?size=10&from=0" -H 'Content-Type: application/json' -d'
{
  "query": {
    "wildcard": {
      "labelValueList.value.keyword": "*57185798*"
    }
  }
}'

13、获取别名

curl -XGET "http://127.0.0.1:9200/accountinterfaceevent_20190411v181/_alias"

14、取消task

curl -XPOST "http://localhost:9200/_tasks/_cancel?actions=*reindex"
或
curl -X POST "localhost:9200/_tasks/oTUltX4IQMOUUVeiohTt8A:12345/_cancel"

15、scroll

curl -X POST "localhost:9200/twitter/_search?scroll=1m" -H 'Content-Type: application/json' -d'
{
    "size": 100,
    "query": {
        "match" : {
            "title" : "elasticsearch"
        }
    }
}'

16、delete by query

curl -XPOST "http://localhost:9201/apievent_20190303/_delete_by_query" -H 'Content-Type: application/json' -d'
{
  "query": {
    "term":{
      "name":"nsh"
    }
  }
}'

17、查询

curl -XGET "http://127.0.0.1:9200/apievent_20190802/_search" -H 'Content-Type:application/json' -d'
{"query":{"term":{"uniqueId":"MTI3LjAuMC4xXzE4OTU0XzE4OTkyXzE1NjQ3MTE2OTU2MTNfNA=="}}}'

18、集群

GET /_cat/nodes?v&h=heap.current,heap.max,query_cache.memory_size,request_cache.memory_size,query_cache.memory_size,search.fetch_current,search.open_contexts,search.query_current,file_desc.current

19、设置集群配置

curl -XPUT "http://localhost:9201/_cluster/settings" -H 'Content-Type: application/json' -d'
{
   "persistent" : {
    "indices.breaker.fielddata.limit" : "40%"
  }
}'

20、获取集群配置

curl -XGET "http://localhost:9201/_cluster/settings"

21、查询index默认的setting配置

curl -XGET "http://127.0.0.1:9200/test/_settings?include_defaults"

22、查询ES状态信息:磁盘、文档数量、已安装插件、cpu、mem使用率

curl -XGET "http://127.0.0.1:9200/_cluster/stats"

23、查询ES所有index的template、settings、mapping、routing_table

curl -XGET "http://127.0.0.1:9200/_cluster/state"

24、配置pipeline

PUT _ingest/pipeline/two
{
  "description" : "timestamp tranfer to Date",
  "processors" : [
    {
      "date" : {
        "field" : "timestamp",
        "target_field" : "@timestamp",
        "formats" : ["UNIX_MS"], 
        "timezone" : "UTC"
      }
    }
  ]
}

25、查询pipeline

GET _ingest/pipeline/two
或
GET _ingest/pipeline

26、功能:所有匹配apievent*的索引都会添加该配置项,创建或更新

PUT _template/apievent
{
  "template": "apievent*",
  "settings": {
"index.mapping.total_fields.limit": 2000
},
"mappings":{
}
}
或
PUT _template/test
{
  "index_patterns": "test*",
  "settings": {
"index.mapping.total_fields.limit": 2000
}
}
curl -XPUT "http://127.0.0.1:9200/_template/eventactiontemplate" -H 'Content-Type: application/json' -d'
{
  "index_patterns": "eventaction*",
  "settings": {
"index.mapping.total_fields.limit": 2000
}
}'

27、功能:删除模板

curl -X DELETE "localhost:9200/_template/template_1"

28、功能:查看模板

curl -X GET "localhost:9200/_template/template_1"
curl -X GET "localhost:9200/_template"
curl -X GET "localhost:9200/_template/temp*"
curl -X GET "localhost:9200/_template/template_1,template_2"
//结果
{
  "order": 0,                               // 模板优先级
  "template": "sample_info*",               // 模板匹配的名称方式
  "settings": {...},                        // 索引设置
  "mappings": {...},                        // 索引中各字段的映射定义
  "aliases": {...}                          // 索引的别名
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

风吹千里

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值