ES5.4.1 命令

1count 命令

curl -XGET 'http://10.202.33.206:9200/incbdpiforder/_count' -d'
{
"query":{
"range": {
"timestamp":{
"gt": "now-5m",
"lt": "now"
}
}
}
}'

 

 

2删除命令  incDay是字符串类型,格式:2017-10-10

curl -XPOST 'http://10.202.35.201:9200/'$index_name'/'$type_name'/_delete_by_query?pretty' -d '
{
  "query": {
"bool":{
"must":[
{
    "range": {
      "incDay":{
      "lt":"'$severaldayago'"
      }
    }
}
]
}
  }
}'

 

 

按照时间类型字段删除数据

 

按时间删除数据

先查询后删除

timestamp 是时间类型

curl -XGET 'http://10.202.13.143:9200/bdpbiedimidxdept/dept/_search?' -d '

{

"query":{

"bool":{

"must":[

{

"range" : { 

"timestamp" : { "from" : "now-90d", "to" : "now-35d" } }

}

],

"must_not": [ ],

"should":[ ]

}

},

"from":0,

"size":10

}'

 

 

 

curl -XPOST 'http://10.202.13.143:9200/bdpbiedimidxdept/dept/_delete_by_query?pretty' -d '

{

  "query": {

"bool":{

"must":[

   {

"range" : { 

"timestamp" : { "from" : "now-90d", "to" : "now-35d" } }

}

]

 

}

  }

}'

 

 

更新refresh时间间隔
curl -XPUT 'localhost:9200/twitter/_settings?pretty' -H 'Content-Type: application/json' -d'
{
    "index" : {
        "refresh_interval" : "-1"
    }
}’

 

 

painless脚本

GET waybillinfo_prophet_monitor/waybill/_search

{

  "query": {

    "bool": {

      "filter": [

        {"range": {

          "urge_deliver_tm": {

            "gte": "2018-11-07 12:00:00",

            "lte": "2018-11-07 23:59:59"

          }

        }

        },

        {

       "exists" : { "field" : "destZoneCode" }

        },

        {

       "exists" : { "field" : "receiverDepartmentCode" }

        },

        {

"script": {

"script": {

"inline": "doc['destZoneCode'].value.length() >= 3&&doc['receiverDepartmentCode'].value.length() >= 3&&doc['destZoneCode'].value.substring(0,3)!=doc['receiverDepartmentCode'].value.substring(0,3)",

"lang": "painless"

}

}

}]

      

    }

  },

  "_source": ["destZoneCode","receiverDepartmentCode","receiverAddr","receiverDepartmentName","waybillNo","_id"],

  "from": 0,

  "size":30

}

 

 

 

通过查询更新数据

POST /index_name/type_name/_update_by_query
{
   "script":{
        "lang":"painless",
        "inline":"if (ctx._source.xxx == null) {ctx._source.xxx= 1561104626000L}"
    }, 
  "query" : {
    "bool" : {
      "filter" : [
        {
                "term" : {
                  "price" : {
                    "value" : "1"
                  }
                }
              }
              ]
              
  }
}
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值