Created
October 27, 2015 09:34
-
-
Save Alino/dc75d5c33db8a4b690e5 to your computer and use it in GitHub Desktop.
elasticsearch top hits query aggregation
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
GET /masterproducts/product/_search | |
{ | |
"query": { | |
"bool": { | |
"must": [{ | |
"term": { | |
"product._all": "zem" | |
} | |
}], | |
"must_not": [], | |
"should": [] | |
} | |
}, | |
"from": 0, | |
"size": 0, | |
"sort": [], | |
"facets": {} | |
, | |
"aggs" : { | |
"categories" : { | |
"terms" : { | |
"field" : "product.category", | |
"order": { | |
"top_hit": "desc" | |
} | |
}, | |
"aggs": { | |
"top_category_hits": { | |
"top_hits": {} | |
}, | |
"top_hit" : { | |
"max": { | |
"script": "_score" | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Content. You can keep this default content for now and make changes to it later. Let’s go ahead and click Continue to Layouts at the bottom of the page to continue.