首页 > 技术文章 > ES日常操作

carry00 2019-01-21 16:44 原文

ES日常操作

查看

查看My_key中存在My_word的参数

GET /index_name/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "My_key.keyword": {
              "value": "My_word"
            }
          }
        }
      ]
    }
  }
}

数字类型,long init float 等不用 keyword

GET my_Index_Name/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "createdAt": {
              "value": "1607236133615"
            }
          }
        }
      ]
    }
  }
}

命令行查询

curl -XGET "http://10.4.16.90:9200/my_Index_Name*/_search" -H "Accept: application/json" -H 'Content-Type: application/json' -d '语句'

查看ES集群设置

GET /_cluster/settings
cluster.routing.allocation.disk.watermark.low: 默认 85% 当达到时,replica 不再写入
cluster.routing.allocation.disk.watermark.high: 默认 90% 当达到时,shards 会尝试写入其他节点
cluster.routing.allocation.disk.watermark.flood_stage: 默认 95% 当达到时,所有索引变为 readonly状态

查询汇总加入参数

"track_total_hits": true,

查询mapping

GET my_Index_Name/_mapping

创建mapping

#先创建索引
PUT my_Index_Name
#创建给空mapping的索引my_Index_Name创建mapping
POST my_Index_Name/_mapping

推荐阅读