Elasticsearch复习笔记

ElasticSearch

  • 倒排索引
    keyword id (倒排索引)

name 1001

zhang 1002

基础操作

索引操作

创建索引
  • index就是等于database (索引)发送put请求 (不能使用功能post)
  • /shoping 就是创建索引
获取索引详细信息
  • /_cat/indices?v 使用get的方式
删除索引
  • /shopping 使用delete

操作文档

  • 是直接在索引中添加的
添加文档
  • post请求
  • 请求体是json格式 放入要存储的数据
  • /shopping/_doc/1001 (这个就是自己的id)
  • /shopping/_create/1001
获得文档
  • 使用get的方式
  • /shopping/_doc/1001
  • 获得这个文档的下的所有的:/shopping/_search
修改
  • 使用put方式
  • 全量数据的修改 /shopping/_doc/1001 然后body里面携带内容
  • 局部修改 /shopping/_update/1001 使用post方式 { "doc":{"title":"nihao"}}
删除
  • /shopping/_doc/1001 使用delete请求
条件查询
  • get
  • /shopping/_search?q=category:小米
  • 使用请求体来传递条件 /shopping/_search
    {
    "query":{
    "match" :{
    "category":"小米"
    }
    }
    }
  • 全量查询
    {
    "query":{
    "match_all" :{
    "category":"小米"
    }
    },
    "form":0,//从第几条开始
    "size":2,// 每页显示两条
    "_source":["title"],
    "sort":{
    "price":{
    "order":"des"
    }
    }
    }
多条件查询

-同时成立

{

"query":{

"bool":{

"must":[{

"match":{

"category":"小米"

}

},{

"match":{

"price":3999.00

}

}]

}

}

}

  • 其中一个成立
    {
    "query":{
    "bool":{
    "should":[{
    "match":{
    "category":"小米"
    }
    },{
    "match":{
    "category":"华为"
    }
    }]
    },
    "filter":{
    "range":{
    "price":{
    "gt":2000
    }
    }
    }
    }
    }
  • 大于成立
    {
    "query":{
    "bool":{
    "should":[{
    "match":{
    "category":"小米"
    }
    },{
    "match":{
    "category":"华为"
    }
    }],
    "filter":{
    "range":{
    "price":{
    "gt":2000
    }
    }
    }
    }
    }
    }
  • 看别人写的笔记 https://blog.csdn.net/u011863024/article/details/115721328
相关推荐
tingshuo291711 小时前
S001 【模板】从前缀函数到KMP应用 字符串匹配 字符串周期
笔记
洛森唛17 小时前
Elasticsearch DSL 查询语法大全:从入门到精通
后端·elasticsearch
Elasticsearch3 天前
如何使用 Agent Builder 排查 Kubernetes Pod 重启和 OOMKilled 事件
elasticsearch
Elasticsearch4 天前
通用表达式语言 ( CEL ): CEL 输入如何改进 Elastic Agent 集成中的数据收集
elasticsearch
西岸行者6 天前
学习笔记:SKILLS 能帮助更好的vibe coding
笔记·学习
starlaky6 天前
Django入门笔记
笔记·django
勇气要爆发6 天前
吴恩达《LangChain LLM 应用开发精读笔记》1-Introduction_介绍
笔记·langchain·吴恩达
悠哉悠哉愿意6 天前
【单片机学习笔记】串口、超声波、NE555的同时使用
笔记·单片机·学习
勇气要爆发6 天前
吴恩达《LangChain LLM 应用开发精读笔记》2-Models, Prompts and Parsers 模型、提示和解析器
android·笔记·langchain
qianshanxue116 天前
计算机操作的一些笔记标题
笔记