Complex nested query in elastic

I have a complex query requirement in elastic and I would like to know if this is possible in elastic.
I have the following data structure in elastic index:

{
 {
   "hostname" : "host1",
   "neighbors" : ["host2", host3"]
 },
 {
   "hostname" : "host2",
   "neighbors" : ["host1", host3"]
 },
 {
   "hostname" : "host3",
   "dc" : "dc1",
   "neighbors" : ["host2", host1"]
 }
}

My end goal is to use the 'neighbors' field to find the "dc" data from the one that already have the info. Basically, since "host1" is neighbor of "host3" and "host3" have the dc info, I should be able to said that "host1" should also have "dc1" as the "dc" info.
I could do this using multiple elastic query in a script like: get "neighbors" from "host1", then go through each hosts to get the dc info, and eventually I would get "dc1" from "host3" and done.
But I would like to know if it is possible to build a single elastic query that would do the above stuffs instead of multiple individual query.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.