我最近开始学习Elasticsearch,并希望合并两个查询。
{
'query': {
'match': {
'title': 'phrase'
}
}
}
和
{
'query': {
'range': {
'@timestamp': {
'gte': 'now-30d',
'lte': 'now'
}
}
}
}
阅读文档,我发现可以与bool进行这种组合,但是我不知道该如何构造。
bool是一个提供四个选项的容器
必须-它的作用类似于AND
应该-它的作用类似于OR
Must_not-类似于NOT
过滤器-用作AND,但不计算分数。
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "phrase"
}
}
],
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-30d",
"lte": "now"
}
}
}
]
}
}
}