Array, Object or Nested type for better performance

(Christophe Rosko) #1

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 :

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

Thanks for your help :smile:

(system) #2