• es crul查询(一)


    C:UsersAdministrator>elasticdump --input=D:	est --output=http://localhost:9200/logs_apipki_20190102
    #查询所有索引信息
    http://localhost:9200/_cat/indices?v
    #轻量级搜索
    curl -X GET "localhost:9200/test/user/_search?q=last_name:Smith"
    
    #表达式搜索
    curl -X GET "localhost:9200/megacorp/employee/_search" -H 'Content-Type: application/json' -d'
    {
        "query" : {
            "match" : {
                "last_name" : "Smith"
            }
        }
    }
    '
    #filter实现结勾化查询
    curl -X GET "localhost:9200/megacorp/employee/_search" -H 'Content-Type: application/json' -d'
    {
        "query" : {
            "bool": {
                "must": {
                    "match" : {
                        "last_name" : "smith" 
                    }
                },
                "filter": {
                    "range" : {
                        "age" : { "gt" : 30 } 
                    }
                }
            }
        }
    }
    '
    #模糊匹配(向下匹配,并根据匹配的分数排序)
    curl -X GET "localhost:9200/megacorp/employee/_search" -H 'Content-Type: application/json' -d'
    {
        "query" : {
            "match" : {
                "about" : "rock climbing"
            }
        }
    }
    '
    #短语搜索(精准匹配)
    curl -X GET "localhost:9200/megacorp/employee/_search" -H 'Content-Type: application/json' -d'
    {
        "query" : {
            "match_phrase" : {
                "about" : "rock climbing"
            }
        }
    }
    '
    #高亮查询
    curl -X GET "localhost:9200/megacorp/employee/_search" -H 'Content-Type: application/json' -d'
    {
        "query" : {
            "match_phrase" : {
                "about" : "rock climbing"
            }
        },
        "highlight": {
            "fields" : {
                "about" : {}
            }
        }
    }
    '
    #聚合函数(类似group by)
    curl -X GET "localhost:9200/megacorp/employee/_search" -H 'Content-Type: application/json' -d'
    {
      "aggs": {
        "all_interests": {
          "terms": { "field": "interests" }
        }
      }
    }
    '
    #先根据query条件过滤,在聚合
    curl -X GET "localhost:9200/megacorp/employee/_search" -H 'Content-Type: application/json' -d'
    {
      "query": {
        "match": {
          "last_name": "smith"
        }
      },
      "aggs": {
        "all_interests": {
          "terms": {
            "field": "interests"
          }
          "aggs" : {//分级聚合各个intrests对应的平均年龄
                    "avg_age" : {
                        "avg" : { "field" : "age" }
                    }
                }
        }
      }
    }
    '
  • 相关阅读:
    CSU-ACM集训-模板-主席树
    Codeforces- Educational Codeforces Round 69
    Codeforces-Round#574 Div2
    CF-1183C Computer Game
    CSU-ACM2019暑假训练(2)
    CSU-ACM2019暑假集训(1)
    2019牛客网第二场-F题
    洛谷P1111 修复公路
    求强连通分量-korasaju算法
    并查集-路径优化+秩优化
  • 原文地址:https://www.cnblogs.com/guozhigang/p/10775671.html
Copyright © 2020-2023  润新知