Reputation: 113
I recently started learning Elasticsearch and am looking to combine two queries.
{
'query': {
'match': {
'title': 'phrase'
}
}
}
And
{
'query': {
'range': {
'@timestamp': {
'gte': 'now-30d',
'lte': 'now'
}
}
}
}
Reading the documentation I saw that it is possible to perform this combination with bool, but I don't know exactly how I structure it.
Upvotes: 1
Views: 53
Reputation: 9109
bool is a container which provides four options
Must- It works like AND
Should - It works like OR
Must_not - It works like NOT
Filter - It works as AND but doesn't calculate score.
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "phrase"
}
}
],
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-30d",
"lte": "now"
}
}
}
]
}
}
}
Upvotes: 2