Elasticsearch 基础查询

Elasticsearch 基础查询

1. term 查询

id查询

{
  "query": {
    "term": {
      "_id": "1574082604628477954"
    }
  }
}

查询某个字段

{
  "query": {
    "term": {
      "orderId": 9876543216
    }
  }
}

2. 分页查询

{
  "from": 0,
  "size": 20,
  "query": {}
}

3. bool 查询

{
  "from": 0,
  "size": 20,
  "query": {
    "bool": {
      "must": [
        {
          "term": { "userPin": { "value": "e9eca00" } }
        }
      ]
    }
  }
}

4. 集群健康

curl -X GET "localhost:9200/_cluster/health?pretty"

返回值

{
  "cluster_name" : "my-application",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 8,
  "active_shards" : 8,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 5,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 61.53846153846154
}

status 字段指示着当前集群在总体上是否工作正常。它的三种颜色含义如下:

  • green 所有的主分片和副本分片都正常运行。
  • yellow 所有的主分片都正常运行,但不是所有的副本分片都正常运行。
  • red 有主分片没能正常运行。

unassigned_shards 没有被分配到任何节点的副本数。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值