Skip to content

Instantly share code, notes, and snippets.

@abulhol
Last active April 28, 2017 04:40
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 abulhol/0869e5c418b77f97e752 to your computer and use it in GitHub Desktop.
Save abulhol/0869e5c418b77f97e752 to your computer and use it in GitHub Desktop.
ES query with top level inner hits that works
{
"query" : {
"bool" : {
"must" : [{
"nested" : {
"path" : "a.b.c.d.first",
"query" : {
"nested" : {
"path" : "a.b.c.d.first.e.f.second",
"query" : {
"bool" : {
"filter" : [{
"term" : {
"a.b.c.d.first.e.f.second.message" : "Nobody expects the Spanish inquisition!"
}
}
]
}
}
}
}
}
}
]
}
},
"inner_hits" : {
"kids0" : {
"path" : {
"a.b.c.d.first" : {
"query" : {
"nested" : {
"path" : "a.b.c.d.first.e.f.second" :
"query" : {
"bool" : {
"filter" : [{
"prefix" : {
"a.b.c.d.first.e.f.second.message" : "Nobody expects the Spanish inquisition!"
}
}
]
}
}
}
},
"size" : 1,
"_source" : false,
"inner_hits" : {
"kids0" : {
"path" : {
"a.b.c.d.first.e.f.second" : {
"size" : 1,
"_source" : [
"message",
"bla",
"blub"
],
"query" : {
"bool" : {
"filter" : [{
"term" : {
"a.b.c.d.first.e.f.second.message" : "Nobody expects the Spanish inquisition!"
}
}
]
}
}
}
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment