I use PostgreSQL 11.8 and faced task, where I need save many sizes for product and need search by sizes too. Before have structure without nested, only one level, without multiply SIZE key
{"SIZE": "98/104", "COLOUR": "Korall", "GENDER": "female", "CURRENCY": "SEK", "AGE_GROUP": "Kids", "ALTERNATIVE_IMAGE": "https://i1.adis.ws/i/Lindex/8016913_8414_PS_MF?w=300&h=300"}
and search I did like that
WHERE ((products_alias.extras @> '{"SIZE":"One Size"}'
OR products_alias.extras @> '{"SIZE":"146/152"}')
AND (products_alias.extras @> '{"COLOUR":"Flerfärgat"}'
OR products_alias.extras @> '{"COLOUR":"Grå"}'
))
But now I need provide opportunity save multiply SIZE and refactor search for that. Example if data will be look like that
{"SIZE": ["38", "90", "12", "4"], "COLOUR": "Svart", "GENDER": "female", "CURRENCY": "SEK", "AGE_GROUP": "Adult", "ALTERNATIVE_IMAGE": "https://i1.adis.ws/i/Lindex/7962770_80_PS_MF?w=300&h=300"}
how build search query for search by SIZE key with OR condition. Like search all where SIZE can contain value 38 or value 4 ?