【发布时间】:2018-09-29 00:41:51
【问题描述】:
我正在通过以下代码以编程方式创建搜索索引。问题是插入设计文档后如何构建索引?还是 .search() 方法第一次使用它?
var book_indexer = function(doc) {
if (doc.author && doc.title) {
// This looks like a book.
index('title', doc.title);
index('author', doc.author);
}
}
var ddoc = {
_id: '_design/library',
indexes: {
books: {
analyzer: {name: 'standard'},
index : book_indexer
}
}
};
db.insert(ddoc, function (er, result) {
if (er) {
throw er;
}
console.log('Created design document with books index');
});
【问题讨论】:
标签: javascript node.js nosql cloudant