我最近开始学习Elasticsearch,并希望合并两个查询。
{
'query': {
'match': {
'title': 'phrase'
}
}
}
和
{
'query': {
'range': {
'@timestamp': {
'gte': 'now-30d',
'lte': 'now'
}
}
}
}
阅读文档后,我发现可以使用 bool 来执行此组合,但是我不知道该如何构造它。
最佳答案
bool(boolean) 是一个提供四个选项的容器
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "phrase"
}
}
],
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-30d",
"lte": "now"
}
}
}
]
}
}
}
关于elasticsearch - 结合Elasticsearch查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61742726/