Skip to content

Instantly share code, notes, and snippets.

@harshvb7
Created September 1, 2018 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harshvb7/53f06bd758d5ca011f255b2de2165a41 to your computer and use it in GitHub Desktop.
Save harshvb7/53f06bd758d5ca011f255b2de2165a41 to your computer and use it in GitHub Desktop.
from elasticsearch import Elasticsearch
client = Elasticsearch()
response = client.search(
index="my-index",
body={
"query": {
"bool": {
"must": [{"match": {"title": "python"}}],
"must_not": [{"match": {"description": "beta"}}],
"filter": [{"term": {"category": "search"}}]
}
},
"aggs" : {
"per_tag": {
"terms": {"field": "tags"},
"aggs": {
"max_lines": {"max": {"field": "lines"}}
}
}
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment