文章目录
- 创建一个文档 index/create
- index 如果id不存在创建新的文档,否则先删除现有的文档,再创建新的文档,版本会增加
- 如果id已经存在,会失败
- 系统会自动生成id
- 更新一个文档 update
- 删除一个文档 delete
- 查一个文档 get
- 批量操作:
- 批量读取:
- 批量查询-msearch
- 总体记录
创建一个文档 index/create
index 如果id不存在创建新的文档,否则先删除现有的文档,再创建新的文档,版本会增加
PUT test/_doc/1
{"user":"mike","comment":"you known,for search"}
如果id已经存在,会失败
PUT test/_create/1
{"user":"mike1","comment":"you known,for search"}
系统会自动生成id
POST test/_doc
{"user":"mike2","comment":"you known,for search"}
更新一个文档 update
文档必须已经存在,更新只会对相应字段做增量修改
POST test/_update/1
{"doc":{"user":"mike4","comment":"you known,for search","test":"55"}}
删除一个文档 delete
DELETE test/_doc/1
查一个文档 get
GET test/_doc/1
批量操作:
批量操作,每一条都有返回,相互不影响
POST _bulk
{"index":{"_index":"test","_id":"1"}}
{"field1":"value1"}
{"delete":{"_index":"test","_id":"2"}}
{"create":{"_index":"test2","_id":"3"}}
{"field1":"value3"}
{"update":{"_id":"1","_index":"test"}}
{"doc":{"field2":"value2"}}
批量读取:
GET _mget
{
"docs":[
{
"_index":"test",
"_id":1
},
{
"_index":"test",
"_id":2
}
]
}
批量查询-msearch
POST test/_msearch
{}
{"query":{"match_all":{}},"from":0,"size":2}
{}
{"query":{"match_all":{}}}
{"index":"test2"}
{"query":{"match_all":{}}}
总体记录
GET _cluster/health
GET _cat/nodes
GET _cat/shards
PUT test/_doc/1
{"user":"mike","comment":"you known,for search"}
PUT test/_create/1
{"user":"mike1","comment":"you known,for search"}
POST test/_doc
{"user":"mike2","comment":"you known,for search"}
GET test/_count
GET test/_doc/1
GET test/_search/
GET test/_doc/1
POST test/_update/1
{"doc":{"user":"mike4","comment":"you known,for search","test":"55"}}
DELETE test/_doc/1
POST _bulk
{"index":{"_index":"test","_id":"1"}}
{"field1":"value1"}
{"delete":{"_index":"test","_id":"2"}}
{"create":{"_index":"test2","_id":"3"}}
{"field1":"value3"}
{"update":{"_id":"1","_index":"test"}}
{"doc":{"field2":"value2"}}
GET _mget
{
"docs":[
{
"_index":"test",
"_id":1
},
{
"_index":"test",
"_id":2
}
]
}
POST test/_msearch
{}
{"query":{"match_all":{}},"from":0,"size":2}
{}
{"query":{"match_all":{}}}
{"index":"test2"}
{"query":{"match_all":{}}}