栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

ES DSL 语句

ES DSL 语句

查看es 版本

$ http://127.0.0.1:9200/

查看所有索引

$ http://127.0.0.1:9200/_cat/indices

创建索引

curl -XPUT 'http://127.0.0.1:9200/tetstindex1/' -d '{  
    "mappings": {
        "testtype1": {
            "properties": {
                "message": {
                    "type": "string"        
                }      
            }    
         }  
}}'

删除索引

$ curl -XDELETe http://127.0.0.1:9200/testindex1

分页查询

curl -XPOST "http://127.0.0.1:9200/index/type/_search?pretty" -d '{  
    "from": 1,
    "size":10000,
    "query": {
        "match_all": {}
  

query  查询语句 

        bool 布尔型

                must 必须 相当于 mysql 的 and

                should    相当于 mysql 的 or

                must_not  不包含

       regexp 正则               

                must 必须 相当于 mysql 的 and

                should    相当于 mysql 的 or

                must_not  不包含

        term 相当于mysql 的count

        range 查询一个范围  

                

aggs 聚合 相当于mysql 的  group

以上 关键字可以配合使用可以嵌套  下面有连个例子

大家可以在kibana 的开发者工具下使用,那里有dsl 语句提示

GET gather-034-20171225/_search
{
  "query": {
    "bool": {
      "must": [
        {"range": {
          "recive_time": {
            "gte": "2017-12-25T01:00:00.000Z",
            "lte": "2017-12-25T02:10:00.000Z"
          }
        }},
        {
          "bool": {
            "should": [
              {"range": {
                "live_delay": {
                  "gte": 1500
                }
              }},
              {
                "range": {
                  "stream_break_count.keyword": {
                    "gte": 1
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}
$ curl -XPOST "http://127.0.0.1:9200/index/_search?pretty" -d '{  
    "size": 0,
    "query":{
        "match": {
            "language":"java"
        }
    },
    "aggs": {
            "sum_cnt": {
                "sum": {
                    "field":"price"
                }
            }
    }
}'

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/721266.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号