POST course/_doc/1
{
"id": 1,
"teacher_id":1,
"course_type":1,
"title": "Golang + Elasticsearch仿慕课网实现企业级搜索实战",
"tag": [
"go",
"es"
],
"weight": 10,
"desc": "go and es 实战课程",
"mtime": 1639728191,
"ctime": 1639728191
}
批量写bulk
POST course/_bulk
{"create":{"_index":"course","_id":2}}
{"id":2,"teacher_id":1,"course_type":2,"title":"go&es","tag":["java","es"],"weight":10,"desc":"go and es 实战课程","mtime":1639728191,"ctime":1639728191}
批量覆盖写
POST course/_bulk
{"index":{"_index":"course","_id":2}}
{"id":2,"teacher_id":1,"course_type":2,"title":"go&es","tag":["java","es"],"weight":10,"desc":"go and es 实战课程","mtime":1639728191,"ctime":1639728191}
修改
单条修改
#更新文档方式1,注意:此种方式必须传递文档的所有参数
POST course/_doc/1
{
"id": 1,
"teacher_id":1,
"course_type":1,
"title": "Golang + Elasticsearch仿慕课网实现企业级搜索实战",
"tag": [
"go",
"es"
],
"weight": 10,
"desc": "go and es 实战课程",
"mtime": 1639728191,
"ctime": 1639728191
}
#更新文档2,此种方式只需要传递待更新的字段
POST course/_update/1
{
"doc": {
"title": "Golang+Elasticsearch实战课程"
}
}