惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
博客园 - 聂微东
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
F
Fortinet All Blogs
C
Check Point Blog
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More

祈雨的笔记

安全多方计算MPC spark原理解析 kueue执行源码分析 spark on k8s执行源码分析 spark-operator源码解析 系统压测遇到的缓存击穿问题 我的世界PC与安卓联机 蚂蚁金服流量投放平台的AIG改造 G1大对象致Old区占用率高 日志打印导致接口响应率下跌分析 Groovy加载类导致OOM分析 ERROR日志打印导致CPU满载 记OceanBase死锁超时 应用发版期间服务响应超时 Ark Serverless初探 系统优化复盘一二三 The user specified as a definer does not exist Kong网关初探 API网关选型调研 CPU火焰图常用工具 配置中心选型调研 root操作Nginx导致用户组错误 基于Proxifier使用代理 FastJSON字段智能匹配踩坑 Nacos初探 记一次Nginx服务器CPU满荷载故障 基于券系统分库分表的思考 limit不参与SQL成本计算致索引失效 Linux常用性能监控命令 golang低版本http2偶现400
elasticsearch简单的CRUD操作
祈雨的笔记 · 2018-09-09 · via 祈雨的笔记

create

1
2
3
4
PUT /index/type/id
{
"key":"value"
}

例如:

1
2
3
4
5
6
7
PUT /ecommerce/product/1
{
"name":"高露洁牙膏",
"desc":"高效美白",
"price":30,
"tags":["美白","防蛀"]
}

delete

1
DELETE /index/type/id

例如:

1
DELETE /ecommerce/product/1

update

1
2
3
4
5
6
POST /index/type/id/_update
{
"doc": {
"key":"value"
}
}

例如:

1
2
3
4
5
6
POST /ecommerce/product/1/_update
{
"doc": {
"name":"佳洁士牙膏"
}
}

read

1
GET /index/type/id

例如:

1
GET /ecommerce/product/1

返回内容过滤

  1. 过滤_source
    1
    GET /index/type/_search?_source=false
1
2
3
4
5
6
7
GET /index/type/_search
{
"query": {
"match_all": {}
},
"_source": false
}
  1. 过滤_source中的部分字段
    1
    GET /index/type/_search?_source_include=key1,key2
1
2
3
4
5
6
7
8
9
GET /index/type/_search
{
"query": {
"match_all": {}
},
"_source": {
"include": ["key1","key2","key3.*"]
}
}
  1. 显示_source中的部分字段
    1
    GET /index/type/_search?_source_exclude=key3
1
2
3
4
5
6
7
8
9
GET /index/type/_search
{
"query": {
"match_all": {}
},
"_source": {
"exclude": ["key3"]
}
}
  1. 只返回_source
    1
    GET /index/type/id/_source

script

例如:

1
2
3
4
5
6
7
POST /ecommerce/product/1/_update
{
"script": {
"params": {"count":2},
"inline": "ctx._source.price += params.count"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
GET /ecommerce/product/_search
{
"query": {
"bool": {
"must": [
{
"script":{
"script":{
"params": {"count":36},
"inline": "doc.price.value == params.count"
}
}
}
]
}
}
}