某个字段存在查询或不存在查询

某个字段存在查询或不存在查询

一、存在查询

1、第一种

GET iptv-monitor-m-gather-apk-20180806/_search
{
    "size": 1,
    "query": {
        "exists": {
            "field": "rtpLossRate"
        }
    },
    "_source":["rtpLossRate"]
}
2、第二种
GET iptv-monitor-m-gather-apk-20180806/_search
{
    "size":1,
    "query":{
        "bool":{
            "must":{
                "exists":{
                    "field":"rtpLossRate"
                }
            }
        }
    },
    "_source":["rtpLossRate"]
}
3、第三种
GET iptv-monitor-m-gather-apk-20180806/_search
{
    "query": {
        "bool": {
            "must": [
                {
                    "exists": {
                        "field": "rtpLossRate"
                    }
                }
            ]
        }
    },
    "_source":["rtpLossRate"]
}

二、不存在查询
1、第一种
GET iptv-monitor-m-gather-apk-20180806/_search
{
    "size":1,
    "query":{
        "bool":{
            "must_not":{
                "exists":{
                    "field":"rtpLossRate"
                }
            }
        }
    },
    "_source":["rtpLossRate"]
}

2、第二种

GET iptv-monitor-m-gather-apk-20180806/_search
{
    "query": {
        "bool": {
            "must_not": [
                {
                    "exists": {
                        "field": "rtpLossRate"
                    }
                }
            ]
        }
    }
}

猜你喜欢

转载自blog.csdn.net/sxf_123456/article/details/81532570