Skip to content

Instantly share code, notes, and snippets.

@jpountz
Created March 7, 2014 13:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jpountz/9411624 to your computer and use it in GitHub Desktop.
Save jpountz/9411624 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