我想做一些类似的事情“和”过滤器示例 http://www.elasticsearch.org/guide/reference/query-dsl/and-filter/除非每个术语中都带有“应该”,而不是示例中的字段类型。我想出了以下几点:
{
"query": {
"bool": {
"must": [
{
"ids": {
"type": "foo",
"values": [
"fff",
"bar",
"baz",
]
}
}
]
}
},
"filter": {
"and": {
"filters": [
{
"bool": {
"should": {
"term": {
"fruit": [
"orange",
"apple",
"pear",
]
}
},
"minimum_should_match": 1
}
},
{
"bool": {
"should": {
"term": {
"color": [
"red",
"yellow",
"green"
]
}
},
"minimum_should_match": 1
}
}
]
}
}
}
但是,我收到此错误:
[bool] filter does not support [minimum_should_match];
还有另一种方法可以完成我正在尝试做的事情,或者我走在正确的轨道上吗?或者这在elasticsearch中是不可能的?
每个 bool 查询子句可以包含多个子句。术语查询 (http://www.elasticsearch.org/guide/reference/query-dsl/terms-query/ http://www.elasticsearch.org/guide/reference/query-dsl/terms-query/) 是指定查询应匹配任何术语列表的简单方法。除了之前的 ids 查询之外,这里使用术语查询来表示水果必须是橙色、苹果、梨之一,颜色必须是红色、黄色、绿色之一:
{
"query": {
"bool": {
"must": [
{
"ids": {
"type": "foo",
"values": [
"fff",
"bar",
"baz"
]
}
},
{
"terms": {
"fruit": [ "orange", "apple","pear" ],
"minimum_should_match": 1
}
},
{
"terms": {
"color": [ "red", "yellow", "green" ],
"minimum_should_match": 1
}
}
]
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)