shrikantgarg17 opened a new issue, #3998:
URL: https://github.com/apache/couchdb/issues/3998

   Hi Team,
   
   We are facing issues while retrieving records from an indexed array. though 
we are not sure if indexing is wrong or querying is wrong but it is taking lot 
of time to get data.
   We are using Couch DB. Here are the details.
   
   {
   "couchdb": "Welcome",
   "version": "3.1.0",
   "git_sha": "ff0feea20",
   "uuid": "c371bc5f-ad93-11eb-b1fa-968ae7512ef5",
   "features": [
   "access-ready",
   "partitioned",
   "pluggable-storage-engines",
   "reshard",
   "scheduler"
   ],
   "vendor": {
   "name": "XXXXX"
   }
   }
   
   We are storing our records in one database whose structure is like this
   {
   "_id": "Test:1a90228b1a6347af9452b51c549c3a49",
   "_rev": "1-1908817280c7fec3dfdd9982c680bee7",
   
   "shri": {
   "tags": [
   "java"
   ],
   "Country": [
   "US"
   ],
   "status": "compliant"
   },
   "tags": {}
   
   "status": "active",
   
   "createTime": 1633684718741,
   "modifyTime": 0
   }
   
   so i want to have index on tags attribute which is an array. below are the 
index which i have created
   {
   "_id": "index1",
   "_rev": "1-56cbb4c9768fd34749b89dfffd446bf7",
   "language": "query",
   "views": {
   "tags-json-index": {
   "map": {
   "fields": {
   "shri.tags": "asc",
   "_id": "asc"
   },
   "partial_filter_selector": {}
   },
   "reduce": "_count",
   "options": {
   "def": {
   "fields": [
   {
   "shri.tags": "asc"
   },
   {
   "_id": "asc"
   }
   ]
   }
   }
   }
   }
   }
   
   and my selector query is :
   
   {"selector": {"$and": [{"shri.tags": {"$elemMatch": {"$eq": "xyz"}}}, 
{"_id": {"$gte": "0"}}]}, "fields": ["_id", "shri""], "sort": [{"_id": "asc"}], 
"limit": 501}
   
   but my query takes lot of time. Not sure if indexing is working properly or 
not.
   
   Below is snippet when i explain my query:
   
   {
   "dbname": "oc-xx-xyz",
   "index": {
   "ddoc": null,
   "name": "_all_docs",
   "type": "special",
   "def": {
   "fields": [
   {
   "_id": "asc"
   }
   ]
   }
   },
   "partitioned": "undefined",
   "selector": {
   "$and": [
   {
   "shri.tags": {
   "$elemMatch": {
   "": {
   "$eq": "xyz"
   }
   }
   }
   },
   {
   "_id": {
   "$gte": "0"
   }
   }
   ]
   },
   "opts": {
   "use_index": [],
   "bookmark": "nil",
   "limit": 501,
   "skip": 0,
   "sort": {
   "_id": "asc"
   },
   "fields": [
   "_id",
   "shri"
   
   ],
   "partition": "",
   "r": [
   49
   ],
   "conflicts": false,
   "stale": false,
   "update": true,
   "stable": false,
   "execution_stats": false
   },
   "limit": 501,
   "skip": 0,
   "fields": [
   "_id",
   "shri"
   
   ],
   "mrargs": {
   "include_docs": true,
   "view_type": "map",
   "reduce": false,
   "partition": null,
   "start_key": "0",
   "end_key": "",
   "direction": "fwd",
   "stable": false,
   "update": true,
   "conflicts": "undefined"
   }
   }
   
   Can anyone please help me on this.
   
   Thanks
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to