Skip to content

Instantly share code, notes, and snippets.

@frodopwns
Last active August 29, 2015 14:18
Show Gist options
  • Save frodopwns/ec4233e349dc3e396abc to your computer and use it in GitHub Desktop.
Save frodopwns/ec4233e349dc3e396abc to your computer and use it in GitHub Desktop.
elastic aggs
import elasticsearch
from pprint import pprint
es = elasticsearch.Elasticsearch()
query = {'size': 0, 'aggs': {'institutions': {'terms': {'field': 'institution', 'size': 10}}}}
res = es.search(index='courses', doc_type='class', body=query)
pprint(res['aggregations'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment