Tree structure and using them in cross document queries

I am trying to model cities and regions in elasticsearch, these would naturally be stored as a tree, whether they would be nested documents or parent child indexes would be dependent on how often we would have to update them.

I also would have another type of document stored, lets call this Restaurant, which would have a parentId that would reference a node in the tree.

I wanted to know if it is possible to make a single query, asking to bring back all restaurants that fall within A?

so if the trees look like this:


the restaurants being returned would be the ones that have parentIds of C,E,H.

It sounds like locations would change quite infrequently, so why not denormalize fully and store the full location information with each restaurant?

That's how we are thinking of implementing it at the moment but I would like to know about alternative approaches and whether what I have in mind is even possible.

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