Last active
April 20, 2016 18:57
-
-
Save djw8605/e3851fe055e6d41575cb3d005a62d240 to your computer and use it in GitHub Desktop.
Snippet to get the record counts from an ElasticSearch cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def GetCountRecords(client, from_date, to_date, query = None): | |
""" | |
Get the number of records (documents) from a date range | |
""" | |
s = Search(using=client, index='gracc-osg-*') \ | |
.filter('range', **{'@timestamp': {'from': from_date, 'to': to_date}}) \ | |
.params(search_type="count") | |
response = s.execute() | |
return response.hits.total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment