gpt4 book ai didi

Elasticsearch - 匹配字符串或空值

转载 作者:行者123 更新时间:2023-11-29 02:54:26 39 4
gpt4 key购买 nike

我必须检查某个字段是否与特定文本匹配或是否为空。有可能吗?

谢谢。

最佳答案

您可以使用 missing 来实现此目的筛选。例如:

POST /my_index/items
{
"field1": "value1"
}

POST /my_index/items
{
"field1": "value2"
}

POST /my_index/items
{
"field1": ""
}

POST /my_index/_refresh

POST /my_index/_search
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"or": {
"filters": [
{
"term": {
"field1": "value1"
}
},
{
"missing": {
"field": "field1"
}
}
]
}
}
}
}
}

关于Elasticsearch - 匹配字符串或空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22635404/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com