elasticsearch 常用查询 + 删除索引 10.0.0.205 + 集群状态诊断 + 多条件查询
1.多条件查询
curl -X POST \ http://10.0.0.42:9200/addressbook_user/_search \ -H 'cache-control: no-cache' \ -H 'content-type: application/json' \ -d '{ "query": { "bool": { "must": [ { "term": { "orgId": { "value": "0db8574bb127466ab03be74ac74235da", "boost": 1 } } }, { "term": { "userId": { "value": "fa3058d8398a455304a3b8e439e29fdd", "boost": 1 } } } ], "adjust_pure_negative": true, "boost": 1 } } }' curl -X POST \ http://10.0.0.35:9200/addressbook_user/_search \ -H 'cache-control: no-cache' \ -H 'content-type: application/json' \ -d '{ "query": { "match": { "userId": "8ad37acb7860e3729c964699287de46e" } } }'
2.删除索引
curl -XDELETE http://10.0.0.7:9200/wxqyh180867134-2019.09.16
curl -XGET '10.0.0.205:9200/_cat/indices?v'
curl -XDELETE '10.0.0.205:9200/*2020.01.21'
---------------------------------------------------------------------------------------------------------
1.与查询
curl -XPOST 'localhost:9200/bank/_search?pretty' -d ' { "query": { "bool": { "must": [ { "match": { "address": "mill" } }, { "match": { "address": "lane" } } ] } } }'
curl -XPOST 'localhost:9200/bank/_search?pretty' -d ' { "query": { "bool": { "should": [ { "match": { "address": "mill" } }, { "match": { "address": "lane" } } ] } } }'
2.非查询
curl -XPOST 'localhost:9200/bank/_search?pretty' -d ' { "query": { "bool": { "must_not": [ { "match": { "address": "mill" } }, { "match": { "address": "lane" } } ] } } }'
-------------------------------------------------------------------------------------------------------
1.查询脚本
#!/bin/bash source ./vars_config.conf #USAGE EXAMPLES #QUERY INDEICES function query_index(){ echo "--------------------indices-----------------------" curl -XGET "$ES_URL/_cat/indices?v&pretty" } #QUERY NODES function query_nodes(){ echo "--------------------nodes-----------------------" curl -XGET "http://$ES_URL/_cat/nodes?v" } #QUERY CLUSTER function query_cluster(){ echo "--------------------cluster mem - cpu -----------------------" curl -XGET "http://$ES_URL/_cluster/stats?pretty" echo "--------------------cluster-----------------------" curl -XGET "http://$ES_URL/_cat/nodes/?v&pretty" } #QUERY ALLOCATION function query_allocation(){ echo "--------------------allocation-----------------------" curl -XGET "http://$ES_URL/_cat/allocation?v" } #QUERY VERSION function query_version(){ echo "--------------------version-----------------------" curl -XGET "http://$ES_URL/?pretty" } #QUERY HELP function query_help(){ echo "--------------------help-----------------------" echo "USAGE EXAMPLE: sh $0 help" echo "parameters: <indices>,<nodes>,<clutser>,<allocation>,<version>,<help>,<all>" } if [[ $# -eq 0 ]];then query_help fi case $1 in indices) # echo "--------------------indices-----------------------" query_index;; nodes) query_nodes;; cluster) query_cluster;; allocation) query_allocation;; version) query_version;; help) query_help;; all) query_nodes query_index query_allocation query_cluster ;; esac
[root@host164 elasticsearch]# cat vars_config.conf ES_URL="192.168.1.49:9200"
用一个例子来演示会更加清晰
分类:
elk
【推荐】国内首个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-09-18 通过cgroup给docker的CPU和内存资源做限制