Skip to content

Instantly share code, notes, and snippets.

@dadoonet
Created July 3, 2014 17:52
Show Gist options
  • Save dadoonet/a04013991566b8a5ec39 to your computer and use it in GitHub Desktop.
Save dadoonet/a04013991566b8a5ec39 to your computer and use it in GitHub Desktop.
Compute terms agg on non analyzed terms.
DELETE test
PUT test
{
"mappings": {
"test": {
"properties": {
"deviceId": {
"type": "string",
"index": "not_analyzed"
},
"basics": {
"properties": {
"sex": {
"type": "string",
"index": "not_analyzed"
},
"device": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
PUT /test/test/1
{
"basics": {
"sex": "m",
"device": "LGE LG-P768"
},
"deviceId": "1"
}
PUT /test/test/2
{
"basics": {
"sex": "m",
"device": "Samsung SHW-M250S"
},
"deviceId": "2"
}
GET /test/test/_search?search_type=count
{
"aggregations": {
"popular_devices": {
"terms": {
"field": "device"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment