Skip to content

Instantly share code, notes, and snippets.

@danielpereirabp
Created January 25, 2017 10:47
Show Gist options
  • Save danielpereirabp/bc4954bf24bf1e7e2878fc7c03bc71df to your computer and use it in GitHub Desktop.
Save danielpereirabp/bc4954bf24bf1e7e2878fc7c03bc71df to your computer and use it in GitHub Desktop.
Elasticsearch Group By
POST /questoes_sf/questao/_search
{
"size": 0,
"query": {
"term": {
"instituicao.dominio": "na"
}
},
"aggs": {
"group_by_comparador": {
"terms": {
"field": "comparador",
"size": 0,
"order": {
"_count": "desc"
},
"min_doc_count": 2
},
"aggs": {
"questoes": {
"terms": {
"field": "id",
"size": 0
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment