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
    }
  }
}
相关推荐
万山寒几秒前
python依赖包导出离线安装到没有外网的服务器
服务器·开发语言·python
扶苏100217 分钟前
同一个 Git 项目整出两份,切分支互不影响?两种方案实测
大数据·git·elasticsearch
zhongerzixunshi20 分钟前
健全创新激励机制,激活企业发展内生动力
大数据·人工智能
程序员雷欧26 分钟前
LongAdder
开发语言·python
71777729 分钟前
软件工程工业化实践:Gitee 智能化软件工厂全链路标准化交付体系解析
大数据·gitee·软件工程
Databend32 分钟前
从 Kafka 到 Databend Cloud:万亿级 Agent Trace 接入链路的工程实践
大数据·数据库·agent
月光船幽幽37 分钟前
分层阈值规避归藏协议过度重置
人工智能·python
SMF191942 分钟前
【Linux】完美解决缩略图工具gm调用java.io.FileNotFoundException: gm问题
java·开发语言·python
㳺三才人子1 小时前
初探 Data Analysis - Matplotlib
python·plotly·pandas·matplotlib
Python私教1 小时前
0、null、未采集:AI Agent 反馈系统最容易踩的语义坑
人工智能·python