我有以下问题文档:
questions
[
{
"name":"A",
"id": 1,
"subjects":[
{
"type":"subject",
"id":"1"
}
],
"topics":[
{
"type":"topic",
"id":"1"
}
]
},
{
"name":"B",
"id": 2,
"subjects":[
{
"type":"subject",
"id":"2"
}
],
"topics":[
{
"type":"topic",
"id":"2"
}
]
},
{
"name":"C",
"id": 3,
"subjects":[
{
"type":"subject",
"id":"3"
}
],
"topics":[
{
"type":"topic",
"id":"3"
}
]
}
]
如何过滤主题为id = [1,2]和主题id = 1
的所有问题我在Kibana控制台上尝试了以下操作:
GET subjects/_search
{
"query": {
"bool": {
"filter": {
"bool": {
"must" : [
{"terms": { "questions.subjects.id": [1,2] }},
{"terms": { "questions.topics.id": [1] }}
]
}
}
}
}
}
但结果仅是问题 A
如果我删除了{"terms": { "questions.topics.id": [1] }}
,则会返回问题 B 。
我也尝试使用本文,但没有成功,https://www.elastic.co/guide/en/elasticsearch/guide/current/combining-filters.html