Query DSL- Exists Query

Exists Query

存在查询

Returns documents that contain an indexed value for a field.

返回字段中包含索引值的文档。

An indexed value may not exist for a document’s field due to a variety of reasons:

由于多种原因,索引值可能不存在于文档的字段中:

  • The field in the source JSON is null or []

  • The field has "index" : false set in the mapping

  • The length of the field value exceeded an ignore_above setting in the mapping

  • The field value was malformed and ignore_malformed was defined in the mapping

  • 源JSON中的字段是null[]

  • 字段在mapping中设置为"index" : false

  • 字段值的长度超出了mapping中设置的ignore_above

  • 字段值格式错误,并且mapping中设置的了ignore_malformed

Example requestedit

GET /_search
{
    "query": {
        "exists": {
            "field": "user"
        }
    }
}

Copy as cURLView in Console

Top-level parameters for exists

exists的一级参数

  • field

    (Required, string) Name of the field you wish to search.

    (必需,字符串)您要搜索的字段的名称。

    While a field is deemed non-existent if the JSON value is null or [], these values will indicate the field does exist:

    如果JSON值为null[],则认为该字段不存在,下面这些值被认为字段存在:

    • Empty strings, such as "" or "-"

    • Arrays containing null and another value, such as [null, "foo"]

    • A custom null-value, defined in field mapping

    • 空字符串,例如"""-"

    • 包含null和另一个值的数组,例如[null, "foo"]

    • 在mapping中设置的自定义null-value

Notes

Find documents missing indexed values
查找缺少索引值的文档

To find documents that are missing an indexed value for a field, use the must_not boolean query with the exists query.

要查找字段缺少索引值的文档,请在must_not 布尔查询 中使用exists查询。

The following search returns documents that are missing an indexed value for the user field.

以下搜索返回字段中缺少user索引值的文档。

GET /_search
{
    "query": {
        "bool": {
            "must_not": {
                "exists": {
                    "field": "user"
                }
            }
        }
    }
}

Copy as cURLView in Console

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值