Elasticsearch中常用curl命令

Elasticsearch5.6中常用curl命令

1.查看集群状态

curl --location --request GET 'http://ip:port/_cluster/health?pretty'

2.查看节点状态

curl --location --request GET 'http://ip:port/_cat/nodes?pretty'

3.查看分片状态

curl --location --request GET 'http://ip:port/_cat/shards?pretty'

4.查看索引列表

curl --location --request GET 'http://ip:port/_cat/indices'

5.查看索引详细信息

curl --location --request GET 'http://ip:port/newgroupuser/_stats?pretty'

6.查看指定索引的文档数量

curl --location --request GET 'http://ip:port/indexName/_mapping'

7.查看指定索引mapping

curl --location --request GET 'http://ip:port/indexName/_mapping?pretty'

8.查看指定索引的settings

curl --location --request GET 'http://ip:port/indexName/_settings?pretty'

9.查询数据

curl --location --request GET 'http://ip:port/indexName/_search?pretty'

10.通过文档id查询数据

curl --location --request GET 'http://ip:port/indexName/doc/c2b157e5-d466-4bb3-9c10-99cba8c513c9_ext'

11.搜索群组

curl --location --request GET 'http://ip:port/indexName/_search?pretty' \
--header 'Content-Type: application/json' \
-d '{
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "id": "5cd3e46be4b04cd13b217f00"
                    }
                }
            ]
        }
    }
}'

12.索引新增字段

curl --location --request PUT 'http://ip:port/indexName/_mapping/doc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "properties":{
          "id": {
                "index": true,
                "store": true,
                "type": "keyword"
              },
               "userName": {
                 "index": true,
                 "store": true,
                 "type": "keyword"
               }
    }
}'

13.查看索引模板

curl --location --request GET 'http://ip:port/_template'

14.es迁移数据

curl --location --request POST 'http://ip:port/_reindex?pretty' \
--header 'Authorization: Basic ZWxhc3RpYzpsam0wMTE3MzIzMQ==' \
--header 'Content-Type: application/json' \
--data-raw '{
    "conflicts": "proceed",
    "source": {
        "remote": {
            "host": "http://ip:port/"
        },
        "index": "indexName",
        "query": {
            "term": {
                "_type": "doc"
            }
        },
        "size": 10000,
        "slice":{
        "id":0,
        "max":5
    }
    },
    "dest": {
        "index": "indexName"
    },
    "script": {
        "inline": "if (ctx._id.length()>512) {ctx._id = ctx._id.substring(0,511)}",
        "lang": "painless"
    }
}'

15.ealsticsearch关闭索引操作

curl --location --request POST 'http://ip:port/indexNametest/_close'

16.elasticsearch打开索引操作

curl --location --request POST 'http://ip:port/indexNametest/_open'

17.elasticsearch动态修改setting中的分词器

curl --location --request PUT 'http://ip:port/indexName/_settings' \
--header 'Content-Type: application/json' \
-d'{
    "analysis": {
        "analyzer":{
             "full_pinyin_analyzer":{
                    "filter":[ "lc_full_pinyin"],
                    "tokenizer":"keyword",
                    "type":"custom"
                }
        }
    }
}'

20.elasticsearch动态添加指定字段mapping

curl --location --request PUT 'http://ip:port/indexName/_mapping/doc' \
--header 'Content-Type: application/json' \
-d '{
    "properties": {
        "userNameFullPinyin": {
            "index": true,
            "store": true,
            "type": "text",
            "analyzer": "full_pinyin_analyzer"
        }
    }
}'
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值