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