肝胆相照的 ES 和 Mysql
概念
ES | SQL |
---|---|
Index | database |
Type | table |
Document | row |
CURD
SQL | ES |
---|---|
增 | curl -X PUT ‘ip:9200/ [ index ] / [ type ] / [ id ] ’ |
删 | curl -X DELETE ‘ip:9200/ [ index ] / [ type ] / [ id ] ’ |
改 | curl -X POST ‘ip:9200/ [ index ] / [ type ] / [ id ] /_update’ |
查 | curl -X GET ‘ip:9200/ [ index ] / [ type ] / [ id ] ’ |
搜 | curl -X GET ‘ip:9200/ [ index ] / [ type ] /_search’ |
花式操作
Func | SQL | ES |
---|---|---|
条件限制 | where field = | query.match.field.value |
字段过滤 | select field | _source : [field, field] |
排序 | order by | sort : [filed.order.desc] |
分页 | offset | from |
分页 | limit | size |
且 | and | query.bool.must.match.field.value |
或 | or | query.bool.should.match.field.value |
否 | not | query.bool.must_not.match.field.value |
大于等于 | >= | query.bool.filter.range.field.gte.value |
小于等于 | <= | query.bool.filter.range.field.lte.value |
term 使用倒排索引精确查询,match 使用分词器模糊查询
字段类型 : text 会被分词器解析,keyword 不会
hits.hits._score : 匹配度
hits.hits._source : 源数据
文章转载自让代码飞,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
MySQL8.0统计信息总结
闫建(Rock Yan)
573次阅读
2025-03-17 16:04:03
MySQL生产实战优化(利用Index skip scan优化性能提升257倍)
chengang
396次阅读
2025-03-17 10:36:40
MySQL数据库当前和历史事务分析
听见风的声音
361次阅读
2025-04-01 08:47:17
墨天轮个人数说知识点合集
JiekeXu
349次阅读
2025-04-01 15:56:03
MySQL 生产实践-Update 二级索引导致的性能问题排查
chengang
335次阅读
2025-03-28 16:28:31
MySQL8.0直方图功能简介
Rock Yan
269次阅读
2025-03-21 15:30:53
MySQL 有没有类似 Oracle 的索引监控功能?
JiekeXu
255次阅读
2025-03-19 23:43:22
云和恩墨杨明翰:安全生产系列之MySQL高危操作
墨天轮编辑部
239次阅读
2025-03-27 16:45:26
openHalo问世,全球首款基于PostgreSQL兼容MySQL协议的国产开源数据库
严少安
238次阅读
2025-04-07 12:14:29
PG vs MySQL 执行计划解读的异同点
进击的CJR
160次阅读
2025-03-21 10:50:08