Last active
July 8, 2016 11:32
-
-
Save jkbnerad/9b49f4e31faeae628181cfb65eb60498 to your computer and use it in GitHub Desktop.
Elasticsearch - top brands
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
{ | |
"aggs": { | |
"nested": { | |
"nested": { | |
"path": "topBrands" | |
}, | |
"aggs": { | |
"filtered": { | |
"filter": { | |
"term": { | |
"topBrands.category": 202 | |
} | |
}, | |
"aggs": { | |
"brands": { | |
"terms": { | |
"field": "topBrands.name", | |
"order": {"max_rank" : "desc"}, | |
"size": 31 | |
}, | |
"aggs": { | |
"hits": { | |
"top_hits": { | |
"sort": [ | |
{ | |
"topBrands.rank": { | |
"order": "desc" | |
} | |
} | |
], | |
"_source": { | |
"include": [ | |
"name", "rank" | |
] | |
}, | |
"size": 1 | |
} | |
}, | |
"max_rank" : { | |
"max" : {"field": "topBrands.rank"} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"size": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment