Elasticsearch 簡單DSL

# 查詢所有索引
GET /_cat/indices?v

# 創建名爲customer的索引
PUT /customer?pretty

# 給customer的索引插入id爲1, name爲test的值
PUT /customer/_doc/2?pretty
{
  "name" : "2test2"
}

# 更新索引表
POST /customer/_doc/1/_update?pretty
{
  "doc" : {"name":"test1", "sex": "f"}
}

#獲取索引爲customer,id爲1的數據
GET /customer/_doc/1?pretty

#刪除索引爲customer中id爲2的數據
DELETE /customer/_doc/2?pretty

# 查詢customer索引中數據
GET /customer/_search?pretty

# 查詢5條customer索引中數據
GET /linux_host/_search
{
  "query":{
    "match_all":{}
  },
  "size": 5
}

#查詢表linux_host,完全匹配
GET /linux_host/_search
{
  "query":{
   "bool": {
      "must": [
        { "match": { "host_ip": "192.168.17.31" } },
        { "match": { "collect_time": "1558429709686" } }
      ]
    }
  }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章