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
    }
  }
}
相关推荐
☆5665 分钟前
机器学习与人工智能
jvm·数据库·python
bjxiaxueliang10 分钟前
一文掌握Python aiohttp:异步Web开发从入门到部署
开发语言·前端·python
belldeep16 分钟前
python:Scapy 网络数据包操作库
网络·python·抓包·scapy
阿kun要赚马内41 分钟前
Python——异常捕获
开发语言·python
顾北1243 分钟前
从零搭建 ELK 栈(ES+Kibana+Logstash):含 IK + 拼音分词,MySQL 同步 ES 完整配置
运维·elasticsearch
2301_804215411 小时前
使用Python进行量化交易入门
jvm·数据库·python
霑潇雨1 小时前
题解 | 深入分析各款产品年总销售额与竞品的年度对比
大数据·开发语言·数据库
wanhengidc1 小时前
服务器托管对企业的作用
大数据·运维·服务器·分布式·智能手机
Code知行合壹1 小时前
Spark使用总结
大数据·分布式·spark
全栈凯哥1 小时前
27.Python datetime 与 time 完全指南
python