Skip to content

Instantly share code, notes, and snippets.

Created August 12, 2011 00:21
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 anonymous/1141158 to your computer and use it in GitHub Desktop.
Save anonymous/1141158 to your computer and use it in GitHub Desktop.
ElasticSearch: nested mapping, data and facet query
{
"query": {
"bool": {
"must": [
{
"range": {
"wired_pages": {
"gt": 1000
}
}
},
{
"nested": {
"path": "processes",
"score_mode": "total",
"_scope": "hung",
"query": {
"field": {
"processes.status": "hung"
}
}
}
}
]
}
},
"facets": {
"process_facet": {
"terms_stats": {
"key_field": "processes.process_name",
"value_field": "processes.count"
},
"scope": "hung"
}
}
}
{
"processlog": {
"properties": {
"wired_pages": {
"type": "integer"
},
"free_pages": {
"type": "integer"
},
"processes": {
"type": "nested",
"include_in_root": 1,
"properties": {
"count": {
"type": "integer"
},
"status": {
"type": "string"
},
"process_name": {
"type": "string"
}
}
}
}
}
}
{
"wired_pages": 1000,
"free_pages": 40,
"processes": [
{
"count": 32,
"status": "hung",
"process_name": "bash"
},
{
"count": 12,
"status": "normal",
"process_name": "ls"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment