[英]ElasticSearch missing and term query
I am trying to fetch documents where is missing field "topic.description" and match term "fundedUnder.programme": "ABC" . 我正在尝试获取缺少字段“ topic.description”和匹配项“ fundedUnder.programme”:“ ABC”的文档 。
Mapping: 制图:
...
"fundedUnder": {
"properties": {
"programme": {
"type": "string"
},
"subprogramme": {
"type": "string"
}
}
},
"topics": {
"type": "nested",
"include_in_parent": true,
"properties": {
"code": {
"type": "string",
"analyzer": "analyzer_keyword"
},
"description": {
"type": "string",
"analyzer": "analyzer_keyword"
},
"title": {
"type": "string",
"analyzer": "analyzer_keyword"
}
}
},
...
My Query looks like: 我的查询看起来像:
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"missing": {
"field": "topics.description"
}
},
{
"term": {
"fundedUnder.programme" : "ABC"
}
}
]
}
}
}
}
}
This query found nothing and that is wrong, because I have in indexes a lot of documents with fundedUnder.programme == "ABC" and with missing field topics.description. 该查询没有发现任何问题,这是错误的,因为我在索引中有很多文档,它们的内容是fundedUnder.programme ==“ ABC”,并且缺少field topic.description。
Thanks in advance. 提前致谢。
ElasticSearch version 1.7.5 ElasticSearch版本1.7.5
I believe this should work: 我相信这应该有效:
EDIT: updated to use version 1.7 Query DSL 编辑:更新为使用1.7版查询DSL
{
"query": {
"filtered": {
"query": {
"match": { "fundedUnder.programme" : "ABC" }
},
"filter": {
"missing": { "field": "topics.description" }
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.