網站首頁 編程語言 正文
Elasticsearch的文檔操作
一 新增文檔
#新增一個id為1的書籍(POST和PUT都可以)
POST lqz/_doc/1/_create
#POST lqz/_doc/1
#POST lqz/_doc 會自動創建id,必須用Post
{
"title":"紅樓夢",
"price":12,
"publish_addr":{
"province":"黑龍江",
"city":"鶴崗"
},
"publish_date":"2013-11-11",
"read_num":199,
"tag":["古典","名著"]
}
二 查詢文檔
#查詢lqz索引下id為7的文檔
GET lqz/_doc/7
#查詢lqz索引下id為7的文檔,只要title字段
GET lqz/_doc/7?_source=title
#查詢lqz索引下id為7的文檔,只要title和price字段
GET lqz/_doc/7?_source=title,price
#查詢lqz索引下id為7的文檔,要全部字段
GET lqz/_doc/7?_source
三 修改文檔
#修改文檔(覆蓋修改)
PUT lqz/_doc/10
{
"title":"xxxx",
"price":333,
"publish_addr":{
"province":"黑龍江",
"city":"福州"
}
}
#修改文檔,增量修改,只修改某個字段(注意是post)
POST lqz/_update/10
{
"doc":{
"title":"修改"
}
}
四 刪除文檔
#刪除文檔id為10的
DELETE lqz/_doc/10
五 批量操作之_mget
#批量獲取lqz索引_doc類型下id為2的數據和lqz2索引_doc類型下id為1的數據
GET _mget
{
"docs":[
{
"_index":"lqz",
"_type":"_doc",
"_id":2
},
{
"_index":"lqz2",
"_type":"_doc",
"_id":1
}
]
}
#批量獲取lqz索引下id為1和2的數據
GET lqz/_mget
{
"docs":[
{
"_id":2
},
{
"_id":1
}
]
}
#同上
GET lqz/_mget
{
"ids":[1,2]
}
六 批量操作之 bulk
PUT test/_doc/2/_create
{
"field1" : "value22"
}
POST _bulk
{ "index" : { "_index" : "test", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "_index" : "test", "_id" : "2" } }
{ "create" : { "_index" : "test", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"_id" : "1", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }
原文鏈接:https://www.cnblogs.com/guyouyin123/p/13308657.html
相關推薦
- 2022-09-24 C#自定義集合初始化器_C#教程
- 2022-01-16 jQuery實現動畫效果和導航欄動態顯示
- 2022-06-23 Pandas中常用的七個時間戳處理函數使用總結_python
- 2022-03-21 C語言中關于scanf函數的一些問題詳解_C 語言
- 2021-12-02 golang配制高性能sql.DB的使用_Golang
- 2022-07-27 P標簽如何取消上下間隔
- 2023-10-15 element-ui里el-progress:進度條問題的解決Invalid prop: custo
- 2022-09-01 Python?類方法和靜態方法之間的區別_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支