function setupViews(db, cb) {
//DESIGN DOCUMENT FOR ACCOUNT
var design = "_design/account";
db.put(design, {
views: {
ByType: {
map: function(doc) {
if (doc.type && doc.type == "account") {
emit(doc.cat, doc);
}
}.toString()
}
},function() {
window.config.accountViews = db([design, "_view"]);
generateCatDesginDoc(db, cb);
//cb(false, db([design, "_view"]));
});
}
http://192.168.1.100:8091/settings/viewUpdateDaemon
On Feb 4, 2015, at 5:50 AM, Vinay Bhinde <vin...@gmail.com> wrote:I have read that it recommended that one should not emit whole document but in this specific use case i need to emit the whole document.
Now i have about 100 documents added to couchbase and when i query this view for the very first time it goes and indexes it and takes about 5~6 seconds to complete and give me a result.
I also read that in native API there is some kind of parameter named "indexUpdateMode" you can use while querying a view which can be used to trigger index update asynchronously in background. What i want is that my view indexes should be automatically updated after specified time interval rather then being updated when queried. I can't find a way to do via REST API for cblite.
You really shouldn't emit the whole document. Why do you need to in this case?
account: "Charity"
cat: "Expense"
channels: "vinay"
createdAt: "Thu Feb 05 2015 00:15:21 GMT-0500 (EST)"
initialBal: "0"
initialBalDate: "Thu Feb 05 2015 00:15:21 GMT-0500 (EST)"
note: ""
subCat: "Activities"
type: "account"
That's a very long time; it should not take that log. (I think I said that before.) Which platform does this occur on, and how big are your documents? Also, what version of CBL?
I'm guessing that your documents are pretty big, so emitting the entire document is slow.
On Feb 4, 2015, at 9:30 PM, Vinay Bhinde <vin...@gmail.com> wrote:But in that case when i need to get all these 100 docs i will have to first query my view which gives me 100 document id's and then i need to fire 100 ajax GET requests to get the complete doc itself. Hence the use of doc in emit of view.
I profiled the app by watching the android logcat logs to find what happens when i query the view for the first time. All it shows is that there is re-indexing of views going on and as there are 100 docs it goes and re-indexes them and that process takes about 5~6 secs. The platform is Android (4.4.4). Also i use this on iOS too and time taken on iOS is little bit less then android.
I don't understand why it's so slow. I'm actually doing benchmarking and optimization on iOS right now, so I have numbers handy. CBL 1.0.3 on my iPhone 6 indexes about 1500 documents per second. (These are docs taken from my iTunes library metadata, they have about as many properties as yours do.) The speed you're quoting is about two orders of magnitude slower!The only difference is Objective-C vs JavaScript for the map function itself, and JS will definitely be slower but it shouldn't be that much slower. I also don't think other PhoneGap developers have run into this in their apps.—Jens
var design = "_design/account";
db.put(design, {
views: {
ByType: {
map: function(doc) {
if (doc.type && doc.type == "account") {
emit(doc.cat, doc);
}
}.toString()
},
BySubCat: {
map: function(doc) {
if (doc.type && doc.type == "account") {
emit(doc.subCat, doc);
}
}.toString()
}
}
}, function() {
window.config.accountViews = db([design, "_view"]);
//generateCatDesginDoc(db, cb);
//cb(false, db([design, "_view"]));
});
On Feb 4, 2015, at 10:37 PM, Vinay Bhinde <vin...@gmail.com> wrote:Also i tested my above view query times without emitting the entire doc itself and emitting null instead. Still it takes 3-4 seconds on average for the first query.