es 文件基本CURD與批量操作

2022-06-26 22:06:13 字數 1674 閱讀 3114

get users/_search

不存在結果:

],"type" : "index_not_found_exception",

"reason" : "no such index [users]",

"resource.type" : "index_or_alias",

"resource.id" : "users",

"index_uuid" : "_na_",

"index" : "users"

},"status" : 404

}

如果存在,則報錯

put users/_create/1

結果:,

"_seq_no" : 0,

"_primary_term" : 1

}存在,報錯:

],"type" : "version_conflict_engine_exception",

"reason" : "[1]: version conflict, document already exists (current version [1])",

"index_uuid" : "b_oynkb4rpq4_eepveq4qa",

"shard" : "0",

"index" : "users"

},"status" : 409

}

存在則覆蓋掉原先文件內容,並文件版本+1

put users/_doc/1

結果:,

"_seq_no" : 1,

"_primary_term" : 1

}

get users/_doc/1

結果:}

更新文件資料,不會覆蓋文件資料,版本號+1

更新文件資料,需求將更新資料放到doc裡面

post users/_update/1

}結果:

, "_seq_no" : 2,

"_primary_term" : 1

}

delete users

結果:

支援在一次ap操作中,對不同索引操作

支援4中型別操作

post _bulk }}

}}}結果:

, "_seq_no" : 2,

"_primary_term" : 1,

"status" : 200}},

,"_seq_no" : 3,

"_primary_term" : 1,

"status" : 404}},

,"_seq_no" : 0,

"_primary_term" : 1,

"status" : 201}},

,"_seq_no" : 4,

"_primary_term" : 1,

"status" : 200}}

]}

需要將多個查詢文件index及_id 以單個子項 放到 以 docs 鍵名的陣列中

get _mget

,

]}結果: },

}]}

文件的基本CRUD與批量操作

cerate 乙個文件 使用http put user create 1 建立,uri 中顯示指定 create,此時如果該id的文件已經存在,操作失敗 get 乙個文件 找不到文件,返回 404 index文件 bulk api 可以在uri中指定index,也可以在請求的payload中進行 操...

ES基礎(三)文件的基本 CRUD 與批量操作

注意 es 6.5.1 為 post users type名 1 update doc create document.指定id。如果id已經存在,報錯 put users doc 1?op type create create document.指定 id 如果已經存在,就報錯 put users...

ES基本操作詳解

工具postman 選擇put方式。表示索引名稱 指定文件id,自動產生文件id 工具postman 選擇put方式 man 1 1就是文件id 工具postman 選擇post方式 自動產生文件id man 直接修改,通過指令碼修改 工具postman 選擇post方式 man 1 update ...