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

你可能感兴趣的:(Elasticsearch)