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
    }
  }
}
相关推荐
仙女修炼史2 小时前
gradcam在yolo中的应用
人工智能·python·yolo
Elasticsearch2 小时前
Elastic:防范由 AI 驱动的社会工程攻击
elasticsearch
李可以量化2 小时前
Redis Client 从了解到精通(六):redis-py 服务控制与状态监控辅助函数详解
python
李可以量化2 小时前
Redis Client 从了解到精通(六)下:redis-py 时间、库管理与持久化辅助函数详解
python
晓窗科技2 小时前
AI基座哪家好
大数据·人工智能·python
麻雀飞吧3 小时前
学量化:看到“近期工具推荐”时,先问工具要解决什么问题
人工智能·python
jayson.h3 小时前
python——pdf编辑
前端·python·pdf
聪明蛋子哟3 小时前
多智能体协作的三种模式:从群聊到分层,如何设计可扩展的Agent系统
后端·python·flask
中科同志科技3 小时前
真空回流炉高温合金元器件焊接炉实操教程:从参数设定到良率提升
大数据·人工智能·机器人·业界资讯
a16252704633 小时前
环保与安全双重约束下全球煤炭供需收缩及其价格上行研究
大数据·人工智能