elasticsearch 常用查询 + 删除索引 + 集群状态诊断
2024-10-19 11:42:29
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":
}
}
},
{
"term": {
"userId": {
"value": "fa3058d8398a455304a3b8e439e29fdd",
"boost":
}
}
}
],
"adjust_pure_negative": true,
"boost":
}
}
}' 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 ]];then
query_help
fi
case $ 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"
最新文章
- Objective-C runtime初识
- C#多线程之基础篇2
- Linux 入门之修改主机名
- ImportError: cannot import name &#39;_imagingtk&#39;
- [原创]html5游戏_贪吃蛇
- smarty访问数组中的数据,如果是关联数组直接用点.
- java报表工具FineReport的SQL编辑框的语法简介
- mysql找回密码
- vs2012 + cocos2d-x 2.1.5 + win7开发环境搭建步骤
- 驾照理论模拟考试系统Android源码下载
- uboot中的mmc命令
- 简单干净的C# MVC设计案例:BrothersDropdownList()
- Servlet程序开发-- Servlet生命周期
- POJ 1848 Tree 树形DP
- ubuntu 创建文件夹和删除文件
- 云服务器 ECS >; 建站教程 >; 部署 LAMP (CentOS 7.2 ,Apache版本:2.4.23, Mysql 版本:5.7.17 , Php版本:7.0.12)
- Oracle 数据备份与恢复
- [转帖]git、github、gitlab之间的关系
- linux command wrap
- python运算符号