Skip to content

Instantly share code, notes, and snippets.

@bragboy
Created March 10, 2019 18:04
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 bragboy/c403775cc26394f563be03b0a132ac86 to your computer and use it in GitHub Desktop.
Save bragboy/c403775cc26394f563be03b0a132ac86 to your computer and use it in GitHub Desktop.
Elasticsearch Collapse and Inner_hits
{
"took": 11,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 12,
"max_score": null,
"hits": [
{
"_index": "employees",
"_type": "_doc",
"_id": "9",
"_score": null,
"_source": {},
"fields": {
"city": [
"Amsterdam"
]
},
"sort": [
"Amsterdam"
],
"inner_hits": {
"order by age": {
"hits": {
"total": 2,
"max_score": null,
"hits": [
{
"_index": "employees",
"_type": "_doc",
"_id": "11",
"_score": null,
"_source": {
"employee": "Emp 11",
"city": "Amsterdam",
"age": 44
},
"sort": [
44
]
},
{
"_index": "employees",
"_type": "_doc",
"_id": "9",
"_score": null,
"_source": {
"employee": "Emp 09",
"city": "Amsterdam",
"age": 40
},
"sort": [
40
]
}
]
}
}
}
},
{
"_index": "employees",
"_type": "_doc",
"_id": "1",
"_score": null,
"_source": {},
"fields": {
"city": [
"Chicago"
]
},
"sort": [
"Chicago"
],
"inner_hits": {
"order by age": {
"hits": {
"total": 5,
"max_score": null,
"hits": [
{
"_index": "employees",
"_type": "_doc",
"_id": "12",
"_score": null,
"_source": {
"employee": "Emp 12",
"city": "Chicago",
"age": 46
},
"sort": [
46
]
},
{
"_index": "employees",
"_type": "_doc",
"_id": "8",
"_score": null,
"_source": {
"employee": "Emp 08",
"city": "Chicago",
"age": 38
},
"sort": [
38
]
}
]
}
}
}
},
{
"_index": "employees",
"_type": "_doc",
"_id": "10",
"_score": null,
"_source": {},
"fields": {
"city": [
"Madrid"
]
},
"sort": [
"Madrid"
],
"inner_hits": {
"order by age": {
"hits": {
"total": 1,
"max_score": null,
"hits": [
{
"_index": "employees",
"_type": "_doc",
"_id": "10",
"_score": null,
"_source": {
"employee": "Emp 10",
"city": "Madrid",
"age": 42
},
"sort": [
42
]
}
]
}
}
}
},
{
"_index": "employees",
"_type": "_doc",
"_id": "2",
"_score": null,
"_source": {},
"fields": {
"city": [
"San Francisco"
]
},
"sort": [
"San Francisco"
],
"inner_hits": {
"order by age": {
"hits": {
"total": 4,
"max_score": null,
"hits": [
{
"_index": "employees",
"_type": "_doc",
"_id": "5",
"_score": null,
"_source": {
"employee": "Emp 05",
"city": "San Francisco",
"age": 32
},
"sort": [
32
]
},
{
"_index": "employees",
"_type": "_doc",
"_id": "4",
"_score": null,
"_source": {
"employee": "Emp 04",
"city": "San Francisco",
"age": 30
},
"sort": [
30
]
}
]
}
}
}
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment