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
    }
  }
}
相关推荐
leoZ2319 分钟前
第 31 篇 金融与医疗:高合规行业的 AI 产品方法论
大数据·人工智能·金融·大模型·agent
阿明副业观察16 分钟前
AI短剧分镜秘籍:从零到电影级视觉冲击
大数据·人工智能·aigc·音视频·ai写作
pride.li17 分钟前
第12章 Python 教程-流程控制:循环结构
linux·服务器·python·算法
Leo.yuan27 分钟前
2026穿透式监管系统选型避坑:数据接不进、风险穿不透、系统难联动,哪些平台能解决?
大数据·数据库
鬼手点金36 分钟前
模型即 Agent:当模型本身成为产品
开发语言·前端·人工智能·python·机器学习
田里的水稻41 分钟前
PyTorch-Dataset\DataLoader数据加载
人工智能·pytorch·python
卷无止境1 小时前
Python 3.14 自由线程:拆掉 GIL 之后,我们到底得到了什么
后端·python
染指11101 小时前
147.Agent-LangGraph归并函数
开发语言·人工智能·python·langchain·agents
Elastic 中国社区官方博客1 小时前
教程:监控 Java 应用
java·开发语言·数据库·elasticsearch·搜索引擎·全文检索
桌管小李1 小时前
内网终端安全再升级|迪康端点安全 2609 版本四大新功能解读
大数据·windows·安全·macos·网络安全