elastic 查询案例Query与Filter + 增删改查简单理解 + dynamic mapping + keyword
1.增 参考:https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html
PUT mytest01/external/1 { "name": "xiaowei" } curl -XPUT '192.168.1.49:9200/mytest/external/1?format=yaml' -H "Content-Type: application/json" -d '{"name":"paxi"}'
2.查
查看索引:curl -XGET http://192.168.1.49:9200/_cat/indices?pretty
GET mytest/_search/ { "query": { "match": { "name": "paxi" } } } curl -XGET 'http://192.168.1.49:9200/mytest/_search/' -H "Content-Type: application/json" -d '{ "query": { "match": { "name": "paxi" } } }'
3.删除
curl -XDELETE http://192.168.1.49:9200/mytest01 参考:https://www.cnblogs.com/jing1617/p/8060421.html
4.查看mapping
curl -XGET http://192.168.1.49:9200/mytest08/_mapping?pretty
5.查看settings
curl -XGET http://192.168.1.49:9200/mytest08/_settings?pretty
--------------------------------------------------------------------------------------
0.模糊查询好的例子
GET /my_index/my_type/_search { "query": { "match": { "title": { "query": "quick~brow~", "fuzziness": "AUTO", "operator": "and" } } } }
参考: https://blog.csdn.net/u011262847/article/details/78007119
1.elasticsearch的devtool短语查询2019-07-18 11:30这个时间的日志document
GET /log47012/doc/_search { "query": { "match_phrase": { "localtime": "2019-07-18 11:30~" } } }
2.kibana的discover的2019-07-18 11:30这个时间的日志document
localtime: "2019-07-18 11:30~"
"2019-07-18 11:30~" --> 相当于一个完整字符串
3.AND discover 查询
"2019-07-18 11:34" AND "中的配置项正在被初始化"
——————————————————————————————————————————
1.匹配符查询
# index a doc PUT index/type/1 { "body": "here" } # and get it ... GET index/type/1 ### get all index GET _cat/indices ### get type GET log4sys-2019.07.19/_search ### query target document GET log4sys-2019.07.19/doc/_search { "query": { "wildcard": { "body": "*he?*e" } } }
----------------------------------------------------------------------------------------------------------------------------------------------
1.查询在Query查询上下文和Filter过滤器上下文中,执行的操作是不一样的:
查询上下文:
在查询上下文中,查询会回答这个问题——“这个文档匹不匹配这个查询,它的相关度高么?”
2.
过滤器上下文:
在过滤器上下文中,查询会回答这个问题——“这个文档匹不匹配?”
复制自:https://www.cnblogs.com/xing901022/p/4975931.html
https://www.cnblogs.com/asker009/p/10174973.html
命令行查询
curl -X POST \ http://10.0.0.35:9200/addressbook_user/_search \ -H 'cache-control: no-cache' \ -H 'content-type: application/json' \ -d '{ "size": 5000, "query": { "bool": { "must": [ { "term": { "userId": { "value": "03a6cc5f1a6d4326a490ddf3547f3a1a", "boost": 1 } } } ], "adjust_pure_negative": true, "boost": 1 } } }'
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
2018-07-18 openshift 入门 部署 openshift-origin-server-v3.7.0