Best way to handle sub documents


I have a problematic about the best way to handle sub documents. My app
have to manipulate companies and a company can have several locations. I
must be able to find companies by their countries or their cities. I don't
need an exact address.

For now, I have the following mapping:

"mappings": {
"company" : {
"properties" : {
"name" : { "type" : "string", "store" : "yes" },
"type" : { "type" : "string", "store" : "yes" },
"employees" : { "type" : "string", "store" : "yes" },
"locations" : {
"country" : { "type" : "string", "store" : "yes" },
"city" : { "type" : "string", "store" : "yes" },
"city" : { "type" : "geo_point", "store" : "yes" },

I would like to have your feedback on several things:

  • What's the best "nested" strategy in my usecase : innerobject (like the example), nested or parent/child? Other? And why?
  • I tried the 3 possibilities but I never successfully find the results of the following query: filtering on a company type ("web agency" for example), a company size and a country. Is it possible?
  • I also use kibana to display some data, but I can't use the nested attributes in the widgets. Is it implemented?

Thanks for your help,

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit