# Best way to handle sub documents

**URL:** <https://discuss.elastic.co/t/best-way-to-handle-sub-documents/15568>\
**Category:** Elasticsearch\
**Created:** [February 3, 2014, 7:12pm UTC](https://discuss.elastic.co/t/best-way-to-handle-sub-documents/15568 "2014-02-03T19:12:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Disneur\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kevin_disneur_2/32/1834_2.png) [@Kevin\_Disneur\_2](https://discuss.elastic.co/u/Kevin_Disneur_2)\
**Post date:** [February 3, 2014, 7:12pm UTC](https://discuss.elastic.co/t/best-way-to-handle-sub-documents/15568/1 "2014-02-03T19:12:05Z")

</div>

Hi,

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,  
Kevin

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d8fb6bce-5760-4a2f-a8ae-9cb7b774eccc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d8fb6bce-5760-4a2f-a8ae-9cb7b774eccc%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:53am UTC](https://discuss.elastic.co/t/best-way-to-handle-sub-documents/15568/2 "2017-07-06T01:53:04Z")

</div>


