# Can i define fields at \_index or at \_type level?

**URL:** <https://discuss.elastic.co/t/can-i-define-fields-at--index-or-at--type-level/51581>\
**Category:** Elasticsearch\
**Created:** [June 1, 2016, 3:27pm UTC](https://discuss.elastic.co/t/can-i-define-fields-at--index-or-at--type-level/51581 "2016-06-01T15:27:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![psilos](https://avatars.discourse-cdn.com/v4/letter/p/c0e974/32.png) [@psilos](https://discuss.elastic.co/u/psilos)\
**Post date:** [June 1, 2016, 3:27pm UTC](https://discuss.elastic.co/t/can-i-define-fields-at--index-or-at--type-level/51581/1 "2016-06-01T15:27:19Z")

</div>

Hi guys, I have the following use case:

1. For a company I need to store all the employees per department. So I am using 1 index for employees and then a separate type for each department. Right now I also have a seperate index "department" where I keep all the info about the departments:  
Employee: {Name, age, etc..}  
Department: {Name, location, population etc..}  
Now Imagine that I need to search for all the employees with a certain hobby and get back the location of the department. I know this is a JOIN case.  
So normally, I have to query the employees first, get back all the matching departments and then query the departments to get back the locations.  
However I was thinking that since, the "department" is the \_type, maybe there is a way to define some fields(properties) at \_type or \_index level which apply for all the docs. Sort of inheritance concept. In this case I ll be able to read the "location" value once I determine all the \_types (departments) that match.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 2, 2016, 1:16am UTC](https://discuss.elastic.co/t/can-i-define-fields-at--index-or-at--type-level/51581/2 "2016-06-02T01:16:50Z")

</div>

You can use parent/child here, where the parent is a department and then the children are the employees.

---

<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 5, 2017, 10:47pm UTC](https://discuss.elastic.co/t/can-i-define-fields-at--index-or-at--type-level/51581/3 "2017-07-05T22:47:05Z")

</div>

Closed on July 5, 2017, 10:47pm UTC


