Getting indexes with timestamp but adding custom hours/minutes/ in elasticsearch Python

Viewed 280

I've been trying to receive all indexes from 7 days ago to now using this type of query:

        query = {'query': {
                        'bool': {
                            'filter': [ 
                                {'range': {'@timestamp':{'gte': now-7d/d,'lte': now/d}}},
                                ]
                            }
                        }
                       }

The problem is I need to get them from let's say: 12 am (midnight) to 11:59 pm. Note: the datetime 'now' can't be hardcoded; it needs to have the exact day, when the script is run. Is it possible to do it without using datetime relying only on built in "data math" in elasticsearch api for Python?

EDIT: To clarify, I need the exact hour to be set to provide exact intervals. Example: getting data at with timestamp between 11:30 am to 12:00 and so on (with 30 minutes interval).

1 Answers
Related