Reputation: 11
I'm using pouchdb module and I have a warning when I search database. Warning message is like this. warning: "no matching index found, create an index to optimize query time"
Why do I have such warning? If someone knows a reason and solution could you tell me it?
var querySentenceDoc = {
_id: '_design/query_sentence',
views: {
by_query_id: {
map: function (doc, ctx) {
ctx.emit(doc.query_id, doc.sentnece_id);
}.toString()
}
}
};
_this.query_sentence.put(querySentenceDoc).then(function () {
_this.query_sentence.query('query_sentence/by_query_id', { stale: 'update_after' }).then(function () {
if (proceedCb) {
proceedCb();
}
return;
});
}).catch(function (err) {
console.log('Sentences views maybe a 409, because it already exists?', err);
});
showSentenceIds: function (ids) {
var param = { keys: ids, limit: 15, include_docs: true};
return this.query_sentence.query('query_sentence/by_query_id', param);
},
models.showSentenceIds(ids).then(function (_s_ids) {
sentenceIds = _s_ids;
callback(null, 0);
});
Upvotes: 0
Views: 1894
Reputation: 219
There's a typo in your design doc:
ctx.emit(doc.query_id, doc.sentnece_id);
So maybe the index isn't built properly. Try changing sentnece_id to sentence_id.
Also, as you're querying on id's, perhaps you can use alldocs instead. See the paragraph about when not to use Map/reduce: https://pouchdb.com/2014/05/01/secondary-indexes-have-landed-in-pouchdb.html
Upvotes: 1