我正在尝试_search
在该领域具有一些特定价值的文件.
{
"query": {
"bool": {
"must": [
{"field": {"advs.status": "warn"}}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
找到了.但是,当我试图在该字段中查找具有空字符串的文档时,我收到此错误:
ParseException[Cannot parse '' ...
Run Code Online (Sandbox Code Playgroud)
然后 - 预期的长列表而不是空字符串.
我试试这个查询:
{
"query": {
"bool": {
"must": [
{"term": {"advs.status": ""}}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
它没有失败但却一无所获.它适用于非空字符串.我该怎么做?
我对这种类型的映射看起来完全像这样:
{
"reports": {
"dynamic": "false",
"_ttl": {
"enabled": true,
"default": 7776000000
},
"properties": {
"@fields": {
"dynamic": "true",
"properties": {
"upstream_status": {
"type": "string"
}
}
},
"advs": {
"properties": {
"status": {
"type": "string",
"store": "yes"
}
}
},
"advs.status": {
"type": "string",
"store": "yes"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
或者更有效地做同样事情的另一种方法是使用exists
过滤器:
"exists" : {
"field" : "advs.status"
}
Run Code Online (Sandbox Code Playgroud)
两者都有效,但这个更好:)
尝试must_not
在missing
您的bool
:
"must_not":{
"missing":{
"field":"advs.status",
"existence":true,
"null_value":true
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9667 次 |
最近记录: |