Elasticsearch 常用命令

1,查看文档总数
curl -XGET ‘http://localhost:9200/_count?pretty’ -d ’
{
“query”: {
“match_all”: {}
}
}

2, DSL 句型 01 查询某关键字, 同时,有一个范围条件

{
    "query" : {
        "filtered" : {
            "filter" : {
                "range" : {
                    "age" : { "gt" : 30 } }
            },
            "query" : {
                "match" : {
                    "last_name" : "Smith" }
            }
        }
    }
}

3,aggs 按照某个字段聚合

# Calculate the most popular interests for all employees
GET /megacorp/employee/_search
{
  "aggs": {
    "all_interests": {
      "terms": {
        "field": "interests"
      }
    }
  }
}

4, 查询某个条件,然后聚合

GET /megacorp/employee/_search
{
  "query": {
    "match": {
      "last_name": "smith"
    }
  },
  "aggs": {
    "all_interests": {
      "terms": {
        "field": "interests"
      }
    }
  }
}

5,查看集群健康

curl -XGET "http://localhost:9200/_cluster/health"

6,改变 副本个数

PUT /blogs/_settings
{
   "number_of_replicas" : 2
}

7, # Delete ALL DATA IN THE CLUSTER!

DELETE /_all
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值