es查询相关


 

 

1.in查询

curl -H "Content-Type: application/json" -XPOST 'http://192.168.1.135:19200/metric_pl/_count?pretty' -d '
{
    "query" : {
        "constant_score" : {
            "filter" : {
                "terms" : { 
                    "month" : ["2022-03-30", "2022-03-31"]
                }
            }
        }
    }
}'

 

2.匹配查询

curl -H "Content-Type: application/json" -XPOST 'http://192.168.1.135:19200/metric_pl/_count?pretty' -d '
{
"query": { "match": {"rt": "777"} }
}'

 

3.查询后更新

curl -H "Content-Type: application/json" -XPOST 'http://192.168.1.135:19200/metric_pl/_update_by_query?pretty' -d '
{
"query": { "match": {"month": "2022-03-25"} },
"script": {
        "source": "ctx._source.rt =777"
    }
}'
curl -H "Content-Type: application/json" -XPOST 'http://192.168.1.135:19200/metric_pl/_update_by_query?pretty' -d '
{
"query" : {"range" : {"id" : {"gte" : 1,"lte"  : 50000000}}},
"script": {
        "source": "ctx._source.rt =777"
    }
}

4.查询所有

curl -H "Content-Type: application/json" -XPOST 'http://192.168.1.135:19200/metric_pl/_count?pretty' -d '
{
"query": { "match_all": {} }
}'