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
    }
  }
}
相关推荐
他是龙5512 分钟前
70:Python安全 & SSTI模板注入 & Jinja2引擎 & 利用绕过 & 工具实战
开发语言·python·安全
m0_676544384 分钟前
MySQL数据库迁移后如何测试数据可读性_进行简单查询验证.txt
jvm·数据库·python
weixin_458580126 分钟前
C#怎么实现定时任务 C#如何用Timer和Quartz.NET创建定时执行的后台任务【技巧】
jvm·数据库·python
果汁华11 分钟前
Claude Agent SDK Python:构建自主 AI 代理的官方引擎
开发语言·人工智能·python
alwaysrun12 分钟前
Python获取Steam平台安装游戏信息
python·游戏·steam·vdf
xinlianyq14 分钟前
DeFi监管框架落地,美国认定多数代币为大宗商品
大数据·人工智能·区块链
qq_4135020218 分钟前
CSS解决浮动布局中最后一行对齐_配合伪类或容器处理
jvm·数据库·python
djjdjdjdjjdj20 分钟前
Less如何优化CSS代码注释风格_利用Less特性保持规范.txt
jvm·数据库·python
m0_6028577620 分钟前
mysql如何编写递归存储过程_mysql max_sp_recursion_depth设置
jvm·数据库·python
WL_Aurora20 分钟前
Python基础知识点全解析:从入门到精通
开发语言·python