I've a cloudant documents that contains this specific structure a json array of category that contains array of subcategories , and i'm trying to write a cloudant query that returns documents with given category_id (for example 128) my problem that it's an array . for example :
"category": {
"sub_category": [
{
"name": {
"en": "Fast food"
},
"category_id": "127"
},
{
"name": {
"en": "Resturans"
},
"category_id": "128"
}
],
}
so far i've tried to write this index :
{
"index": {},
"type": "text"
}
to index everything and a selector :
{"category.sub_category":{"$elemMatch" : {"category_id": {"$gt": 128" }}}
but it doesn't work. any help?