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"
                }
            }
    }
}'

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值