zoukankan      html  css  js  c++  java
  • ElasticSearch学习

    ElasticSearch学习

    分组:

    按series_name字段分组取前几条数据:

    {
      "query": {
        "bool": {
          "filter": [
            {
              "range": {
                "request_time": {
                  "gt": "2019-07-03",
                  "lt": "2019-07-05"
                }
              }
            },
            {
              "bool": {
                "must": [
                  {
                    "match_phrase": {
                      "province_code": {
                        "query": "00644"
                      }
                    }
                  }
                ]
              }
            }
          ]
        }
      },
      "aggs": {
        "group_by_series_name": {
          "terms": {
            "field": "series_name.keyword",
            "size": 5,
            "order": {
              "_count": "desc"
            }
          }
        }
      },
      "size": 0
    }
    View Code

    match_all: 全部查询

    GET dw_app_car_offering_price_ds/_search
    {
      "query": {
        "match_all": {}
      }
    }
    View Code

    单个查询

    GET dw_app_car_offering_price_ds/_search
    {
      "query": {
          "term": {
          "model_code": {
            "value": "12550-n"
          }
        }
      }
    }
    View Code

    size:默认10条

    GET dw_app_car_offering_price_ds/_search
    {
      "query": {
          "term": {
          "model_code": {
            "value": "12550-n"
          }
        }
      },
      "size": 20
    }
    View Code

    from  size :从某个from索引的size条数据

    GET dw_app_car_offering_price_ds/_search
    {
      "query": {
          "term": {
          "source": {
            "value": "che168"
          }
        }
      },
      "from": 10, 
      "size": 10
    }
    View Code

    sort  :排序

    GET dw_app_car_offering_price_ds/_search
    {
      "query": {
        "bool": {
          "must": [
            
            {
              "term": {
              "model_code": {
                "value": "201795"
              }
              }
              
            },
            {
              "term": {
                "source": {
                  "value": "che168"
                }
              }
            },
            {
              "term": {
                "city_code": {
                  "value": "00002"
                }
              }
            }
            
          ]
        }
      },
      "size": 100,
      "sort": [
        {
          "ds": {
            "order": "desc"
          }
        }
      ]
    }
    View Code

    _source:条件查询

    GET dw_app_car_offering_price_ds/_search
    {
      "query": {
          "term": {
          "model_code": {
            "value": "12550-n"
          }
        }
      },
      "_source": ["offering_price_50","city_code"]
    }
    View Code

     参考:https://www.cnblogs.com/pilihaotian/p/5830754.html

    2.0的语法:

    http://www.ischoolbar.com/EsParser/

  • 相关阅读:
    数据源ObjectDataSource的数据访问类的编写
    ASP.NET网页文本编辑器的使用
    装饰模式
    策略模式
    代理模式
    备份、还原数据库
    简单工厂和工厂模式
    ASP.NET上传多个文件
    数据库访问类的编写
    UVA 11069 A Graph Problem
  • 原文地址:https://www.cnblogs.com/wanghongye/p/10993627.html
Copyright © 2011-2022 走看看