zoukankan      html  css  js  c++  java
  • 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"
  • 相关阅读:
    String与StringBuffer常用API
    Java常用类库与工具课后习题3-5
    Java异常课后习题编程题
    Java异常课后习题简答题
    Visio的快速使用和功能理念
    Google免费新书-《构建安全&可靠的系统》
    名字的由来
    日志分析-利用grep,awk等文本处理工具完成(2019-4-9)
    关于docker--详解安装,常规操作,导入导出等(2017-3-29)
    Thinkphp5-0-X远程代码执行漏洞分析(2019-1-11)
  • 原文地址:https://www.cnblogs.com/hixiaowei/p/11543853.html
Copyright © 2011-2022 走看看