ElasticSearch简称ES基础语法使用大全

目录

一、查

1.匹配查询

注意:字符串搜索时,会对输入的查询字符串进行分析和分词,可能导致意外匹配或未匹配。

bash 复制代码
#搜索
GET /your_index/_search
{
  "query": {
    "match": {
    "news_id" : 100
  }}
}

2. 精确匹配字符串

注意:term 查询日期字符串时,因为映射方式不同可能存在匹配不到

bash 复制代码
GET /your_index/_search
{
  "query": {
    "term": {
    "title.keyword" : "superman"
  }}
}

3.匹配某字段为空

bash 复制代码
GET /your_index/_search
{
  "query": {
    "term": {
    "name.keyword" : ""
  }}
}

二、改

1. 通过es_id修改内容

bash 复制代码
POST /your_index/_update/es_id
{"doc": {
  "new_id": "123",
  "name": "小明",
  "status": 1
}}

2. 匹配修改内容

bash 复制代码
POST /your_index/_update_by_query
{
  "script": {
    "source": "ctx._source.status = 1"
  },
  "query": {
    "match": {
    "status " : 2
  }}
}

二、增

1.添加单个文档

bash 复制代码
POST /your_index/_doc
{
  "name" : "yunxiao",
  "age" : 18
}

三、删

1.通过_id删除

bash 复制代码
DELETE /your_index/_doc/_id_123456

2.匹配删除

bash 复制代码
POST /your_index/_delete_by_query
{
  "query": {
    "match": {
      "status": 0
    }
  }
}
相关推荐
用户03321266636713 分钟前
使用 Python 在 Excel 中创建折线图和条形图
python·excel
新*1 小时前
ES 7.17 三节点 Docker 集群的自动备份:从 NFS 被拦住到用 ACL 根治权限
运维·elasticsearch·docker·slm·快照备份
木子欢儿2 小时前
Ubuntu 26.04 LTS 安装Python 3.12
linux·运维·服务器·python·ubuntu
Wellijohn2 小时前
Python 异步并发:我把 5 个坑踩完了,你照着抄模板就行
python
AI创界者2 小时前
Python 进阶实战(六十二章):分布式定时任务、异步工作流与幂等补偿机制实战
人工智能·python·aigc
岳涛2 小时前
ES Transform 通知别名 7.x 迁 8.x 时自动建,9.0 起新建的不再有、存量照旧
elasticsearch
岳涛2 小时前
数值照旧填、请求没报错,ES 9.3 把 max_size 换成按主分片算,索引要更大才滚动
elasticsearch
Elasticsearch2 小时前
Kibana 自定义面板:用一条提示词生成任意仪表板可视化
elasticsearch
演艺大赏3 小时前
Doris 生产运维手册
大数据
如夏倾城3 小时前
网络安全态势感知全解析:概念、架构、厂商与旁路/串联接入选型
大数据·运维·网络·web安全·架构·知识图谱