Skip to content

Instantly share code, notes, and snippets.

@Alino
Created October 27, 2015 09:34
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 Alino/dc75d5c33db8a4b690e5 to your computer and use it in GitHub Desktop.
Save Alino/dc75d5c33db8a4b690e5 to your computer and use it in GitHub Desktop.
elasticsearch top hits query aggregation
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"
}
}
}
}
}
}
Copy link

ghost commented Oct 27, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment