有没有办法将多个条件应用于elasticsearch中的post_filter?
GET /job/_search
{
"post_filter":
{
"terms": {
"expertise_level": [
"medium",
"high"
]
}
},
"aggs": {
"expertise_level": {
"terms": {
"field": "expertise_level",
"size": 10
}
}
}
}
这会奏效。但我想在查询中添加多个过滤器。我怎么能实现这个?
答案 0 :(得分:2)
使用bool
子句:
{
"post_filter": {
"bool": {
"must": [
{
//Add Filter 1
},
{
//Add Filter 2
},
{
//Add Filter 3
}
]
}
}
}
答案 1 :(得分:2)
尝试
{
"post_filter": {
"and": {
"filters": [
{
"terms": {
"FIELD": [
"VALUE1",
"VALUE2"
]
}},
{
"terms": {
"FIELD": [
"VALUE1",
"VALUE2"
]
}
}
]
}
}
}