Skip to content

Instantly share code, notes, and snippets.

@mustafayildirim
Forked from jpountz/nested_example.json
Created November 9, 2016 09:04
Show Gist options
  • Select an option

  • Save mustafayildirim/fe8871d876f164d4f076404d00ee7f11 to your computer and use it in GitHub Desktop.

Select an option

Save mustafayildirim/fe8871d876f164d4f076404d00ee7f11 to your computer and use it in GitHub Desktop.
DELETE /test
PUT /test
{
"mappings": {
"person": {
"properties": {
"name": { "type": "string" },
"attributes": {
"type": "nested",
"properties": {
"name": { "type": "string", "index": "not_analyzed" },
"value": { "type": "string", "index": "not_analyzed" }
}
}
}
}
}
}
PUT /test/person/1
{
"name": "Adrien Grand",
"attributes": [
{
"name": "height",
"value": "180cm"
}
]
}
PUT /test/person/2
{
"name": "John Smith",
"attributes": [
{
"name": "height",
"value": "185cm"
},
{
"name": "weight",
"value": "82kg"
}
]
}
POST /test/_refresh
GET /test/person/_search
{
"aggs": {
"attributes": {
"nested": {
"path": "attributes"
},
"aggs": {
"name_counts": {
"terms": {
"field": "attributes.name"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment