1. 程式人生 > 其它 >ES 基本操作

ES 基本操作

儲存修改二合一

put my-index-000001/_doc/1
{
  "@timestamp": "2099-11-15T13:12:00",
  "message": "GET /search HTTP/1.1 200 1070000",
  "user": {
    "id": "kimchy"
  }
}


POST my-index-000001/_doc/
{
  "@timestamp": "2099-11-15T13:12:00",
  "message": "GET /search HTTP/1.1 200 1070000",
  "user": {
    "id": "kimchy"
  }
}


POST my-index-000001/_doc/1
{
  "@timestamp": "2099-11-15T13:12:00",
  "message": "GET /search HTTP/1.1 200 1070000",
  "user": {
    "id": "kimchy"
  }
}

put ID如果為空 會報錯

刪除

DELETE /my-index-000001/_doc/1

簡單查詢

GET /my-index-000001/_search

複雜查詢彙總

GET /my-index-000001/_search
{"query":{"term":{"user.id":"kimchy"}}}




GET my-index-000001/_msearch
{}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 2}
{"index" : "my-index-000002"}
{"query" : {"match_all" : {}}}





GET /my-index-000001/_search
{"query": {"multi_match": {
  "query": "kimchy",
  "fields": ["user.id","user.id.keyword"]
}}}
 
 




GET /my-index-000001/_search
{"query": {"match_phrase": {
  "user.id": "1"
}}}