Search documents with specific field value in time range

I want to search all documents that have a field "logLevel" set to "WARNING" in the last 24 hours. How do I have to format this query for _search or python elasticsearch? This is my current query:
"query":
{
"term": {"logLevel": "WARNING"},
"range": {
"timestamp": {
"gte": "now-1d/d",
"lt": "now/d"
}
}
}

The error message is:
'parsing_exception', '[term] malformed query, expected [END_OBJECT] but found [FIELD_NAME]'

Thanks!

You need to use a bool query and put your 2 clauses in the must array.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.