elasticsearch基本操作笔记

1.通过kibana查看elasticsearch版本信息

a.左上角三道横->Management->Dev Tools

b.GET / 执行

c.执行结果

{

"name" : "xxxx",

"cluster_name" : "xxxxxxx",

"cluster_uuid" : "vl1UudAoQp-aHWAzyPoMyw",

"version" : {

"number" : "7.15.1",

"build_flavor" : "default",

"build_type" : "docker",

"build_hash" : "83c34f456ae29d60e94d886e455e6a3409bba9ed",

"build_date" : "2021-10-07T21:56:19.031608185Z",

"build_snapshot" : false,

"lucene_version" : "8.9.0",

"minimum_wire_compatibility_version" : "6.8.0",

"minimum_index_compatibility_version" : "6.0.0-beta1"

},

"tagline" : "You Know, for Search"

}

2.精确排除字符串查询

context:"xx" AND NOT location:"xxx" AND NOT location:"xxx" AND NOT location:"xxx"

3.elasticsearch分桶统计key为traceId的value相同个数大于1的所有key和count

GET /bff-prod*/_search

{

"size": 0, // 不返回原始文档

"aggs": {

"duplicate_traceids": {

"terms": {

"field": "ext.traceId.keyword", // 确保使用keyword类型字段

"min_doc_count": 2, // 只返回出现2次以上的结果

"size": 1000 // 覆盖所有重复项(按需调整)

}

}

}

}

4.按关键字统计个数

GET /bff-prod*/_search

{

"size": 0,

"aggs": {

"duplicate_traceids": {

"terms": {

"field": "ext.traceId.keyword",

"min_doc_count": 2,

"size": 1000

}

}

}

}

# 5.带认证的连接

es = Elasticsearch(

'https://10.126.141.98:9200',

basic_auth=("elastic", "z7aJPPruXz9tk26r"),

verify_certs=False # 自签名证书需关闭验证:ml-citation{ref="4" data="citationList"}

)

5.elasticsearch查询昨天的数据,分桶统计traceId字段的值重复个数大于1的key和doc_count;

GET /bff-prod*/_search

{

"query": {

"range": {

"@timestamp": {

"gte": "now-1d/d",

"lt": "now/d",

"time_zone": "+08:00"

}

}

},

"aggs": {

"duplicate_traces": {

"terms": {

"field": "ext.traceId.keyword",

"min_doc_count": 2,

"size": 10000

},

"aggs": {

"bucket_filter": {

"bucket_selector": {

"buckets_path": {

"docCount": "_count"

},

"script": "params.docCount > 1"

}

}

}

}

},

"size": 0

}

相关推荐
Elasticsearch10 小时前
AI 整合:为什么平台将胜出,而产品组合将瓦解
elasticsearch
七牛开发者10 小时前
为什么 Go 很适合 AI 辅助开发?
数据库·人工智能·python·elasticsearch·log4j
Aphelios38011 小时前
一次锁内网络IO引发的Tomcat线程池“饿死”事故
java·开发语言·spring boot·elasticsearch·tomcat·网络io阻塞·线程池耗尽
Elasticsearch16 小时前
向数据源提问:使用 Elasticsearch 和 Elastic Agent Builder 将代码搜索扩展到十亿行代码规模
elasticsearch
-今昭-19 小时前
AnsibleVault加密配置及zabbix部署
大数据·elasticsearch·搜索引擎
Elastic 中国社区官方博客1 天前
跳过有状态的 OTel Collector:Elasticsearch 9.5 原生存储两种指标时间类型
大数据·人工智能·elasticsearch·搜索引擎·重构·全文检索
PC2005-cloud2 天前
Elasticsearch 学习笔记:集群实战(3 控制节点 + 3 数据节点部署与故障转移)
笔记·学习·elasticsearch
Devin~Y2 天前
从内容社区到AI智能客服:Spring Boot + Spring Cloud + Spring AI 全栈实战面试拆解
java·spring boot·redis·elasticsearch·spring cloud·kafka·mybatis
凤山老林2 天前
复杂检索引擎落地:Spring Boot + Elasticsearch 数据同步与高阶查询实战
spring boot·后端·elasticsearch
Elastic 中国社区官方博客3 天前
你的 AI agent 不需要你的 API 密钥:使用 OAuth 2.1 对 Elasticsearch MCP 服务器进行身份验证
大数据·运维·人工智能·elasticsearch·搜索引擎·全文检索