es-api玩法手册

es-api玩法手册,第1张

es-api玩法手册 创建索引

预先设定好索引的setting和mapping

##创建索引 mapping+setting
PUT lsm-kibana_sample_data_flights
{
  "settings": {
    "number_of_shards": 5,
    "number_of_replicas": 1
  }
  , 
  "mappings" : {
      "properties" : {
        "AvgTicketPrice" : {
          "type" : "float"
        },
        "Cancelled" : {
          "type" : "boolean"
        },
        "Carrier" : {
          "type" : "keyword"
        },
        "Dest" : {
          "type" : "keyword"
        },
        "DestAirportID" : {
          "type" : "keyword"
        }
      }
    }
}
reindex索引

重新设定索引的setting和mapping,并进行数据迁移

POST _reindex
{
  "source": {
    "index": "kibana_sample_data_flights"
  },
  "dest": {
    "index": "lsm-kibana_sample_data_flights"
  }
}
聚合 *** 作
    针对某个字段分组统计数量
# Zurich Airport
POST lsm-kibana_sample_data_flights/_search
{
  "size": 0, 
  "aggs": {
    "count_agg": {
      "terms": {
        "field": "DestWeather",
        "size": 3
      }
    }
  }
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5701698.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存