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"