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
    }
  }
}
相关推荐
cc5725026533 小时前
高考志愿填报:大数据相关专业到底怎么选?
大数据·高考
本旺3 小时前
Elasticsearch 前缀匹配性能优化实战,附4种方式即执行计划判别
大数据·elasticsearch·性能优化
hhzz3 小时前
Python大数据实战(十六):音乐推荐系统——基于协同过滤算法构建个性化歌单引擎
大数据·人工智能·python·数据挖掘·数据分析
SunnyDays10114 小时前
Python PDF 转 Markdown 详解(转换整个文档,特定页面,表格,扫描 PDF)
python·pdf 转 markdown·pdf 转 md·扫描 pdf 转 md·pdf 表格转 md
2601_954706494 小时前
云手机 API 自动化实战:Python 批量控机、挂机脚本完整实现
python·智能手机·自动化
泛普软件5 小时前
工程合约管理软件具备哪些核心功能,解决合同结算各类纠纷难题
大数据·人工智能·区块链
Elastic 中国社区官方博客8 小时前
Elastic 在 Everest Group 企业搜索产品 PEAK Matrix® 评估 2026 中被评为领导者
大数据·运维·人工智能·elasticsearch·搜索引擎·ai·全文检索
Alan_6918 小时前
聊聊 Swagger/Postman/Apifox 的真实选型与 Python 项目实战
python·测试工具·postman
智慧物业老杨9 小时前
物业绿化数智化权责管控方案:基于工单平台的双层权限追溯模块落地实践
python
重庆传粉科技9 小时前
传粉科技助力美国房产经纪企业Homequest开拓中国市场
大数据·人工智能