Created
September 1, 2018 11:24
-
-
Save harshvb7/53f06bd758d5ca011f255b2de2165a41 to your computer and use it in GitHub Desktop.
This file contains 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
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