ES 多个terms布尔查询和range过滤的组合
terms布尔查询和range过滤
·
GET index1/doc/_search
{
"query": {
"bool": {
"must": {
"terms": {
"title": [
"日本","核泄漏"
]
}
},
"filter": {
"range": {
"publish_at": {
"gte": "2021-04-13T00:00:00.000Z"
}
}
}
}
},
"sort": {
"publish_at": {
"order": "desc"
}
},
"size": 10
}
{
"query": {
"bool": {
"should": [
{
"terms": {
"title": [
"中国"
]
}
},
{
"terms": {
"content": [
"中国"
]
}
}
],
"must_not": [
{
"terms": {
"title": [
"美国",
"日本"
]
}
},
{
"terms": {
"content": [
"美国",
"日本"
]
}
}
],
"filter": {
"range": {
"publish_at": {
"gte": "2021-01-01T00:00:00.000Z"
}
}
},
"minimum_should_match":1
}
},
"sort": {
"publish_at": {
"order": "desc"
}
},
"size": 10
}
参考
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html
更多推荐
已为社区贡献6条内容
所有评论(0)