I work with Jas, was just wondering if I could add something that might clarify.
Here’s something similar, in Swift, using version 1.4.1 of the Couchbase SDK :
View named “list.items_in_folder_multi_key”
let map : CBLMapBlock = {doc,emit in
guard let docId = doc["_id"] as? String else { return }
guard docId.hasPrefix("files.system.") else { return }
let gid = CBUtils.groupIdFromDocumentId(docId)
let aid = CBUtils.accountIdFromGroupdId(gid)
guard let folder = doc["folder"] as? String else { return }
emit([aid,folder], nil) // aid : Int, folder : String
}
In interest of completeness, here’s my other view where I’ve got a single combined key:
View named “list.items_in_folder”
let map : CBLMapBlock = {doc,emit in
guard let docId = doc["_id"] as? String else { return }
guard docId.hasPrefix("files.system.") else { return }
let gid = CBUtils.groupIdFromDocumentId(docId)
let aid = CBUtils.accountIdFromGroupdId(gid)
guard let folder = doc["folder"] as? String else { return }
let key = "\(aid):\(folder)"
emit(key, nil)
}
I get results only for my single key view “list.items_in_folder”, getting nothing for the “list.items_in_folder_multi_key” view.
Here’s me doing the queries using a single key view, a multi key view and the all docs query with an id prefix query:
queryView(named:"list.items_in_folder",configure:{query in
query.mapOnly = true
query.keys = ["117:/data/2046 ebrd level 2/content"]
})
queryView(named:"list.items_in_folder_multi_key",configure:{query in
query.mapOnly = true
query.keys = [[117],["/data/2046 ebrd level 2/content"]]
})
queryTable(named:"files.system.117.1eHjrdArxIkaD6tzW45E",key:"/data/2046 ebrd level 2/content")
I get the following results:
Queried view 'list.items_in_folder', got 16 rows, took: 7.450544 ms
Queried view 'list.items_in_folder_multi_key', got 0 rows, took: 0.939741 ms
Queried table 'files.system.117.1eHjrdArxIkaD6tzW45E', got 16 rows, took: 22.891379 ms
The multi key query simply isn’t working.