# Array, Object or Nested type for better performance

**URL:** <https://discuss.elastic.co/t/array-object-or-nested-type-for-better-performance/31902>\
**Category:** Elasticsearch\
**Created:** [October 9, 2015, 11:10am UTC](https://discuss.elastic.co/t/array-object-or-nested-type-for-better-performance/31902 "2015-10-09T11:10:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christophe\_Rosko](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@Christophe\_Rosko](https://discuss.elastic.co/u/Christophe_Rosko)\
**Post date:** [October 9, 2015, 11:10am UTC](https://discuss.elastic.co/t/array-object-or-nested-type-for-better-performance/31902/1 "2015-10-09T11:10:59Z")

</div>

Hi !

I have a field which represents countries in which my videos can be broadcasted.  
For each country I have a value which can be 0, 1 or 2. All countries aren't mentioned in the field. For example :  
{"GB":1, "FR":2, "DE":0, "US":1}.

I have to filter on these values : for example check if "countries.GB" exists and is greater than 0.  
I also have to sort on the value of "countries.GB" .

I'm currently storing countries as an object like above but I understand this is not a good idea because it creates many fields in the mapping. I guess it's better to store it in this format :  
[{"country":"GB","value":1},{"country":"FR","value":2},{"country":"DE","value":0},{"country":"US","value":1}]

Is it right ?  
If yes, which type should be used in the mapping for better performance ? Array, Object or Nested ?

Thanks for your help 😄

---

<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, 11:45pm UTC](https://discuss.elastic.co/t/array-object-or-nested-type-for-better-performance/31902/2 "2017-07-05T23:45:40Z")

</div>


