elasticsearch date range get yesterday
Try this:
"query": {
"range": {
"price": {
"gte": "now-1d/d",
"lt": "now/d"
}
}
}
The answer from @andrei-stefan is the way to do this, but I wanted to add a little extra example for other people hitting this question.
If you wanted to get data from yesterday between 12:00pm and 1:00pm rather than the whole day, you could do that with a little more date math:
"query": {
"range": {
"price": {
"gt": "now-1d/d+12h",
"lt": "now-1d/d+13h"
}
}
}
https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math