【问题标题】:How to build cloudant index once desing document created?创建设计文档后如何建立云索引?
【发布时间】: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


    【解决方案1】:

    一旦您插入(格式正确的)设计文档,就会自动创建索引。不需要采取进一步行动。实际索引是在文档创建、更新和删除而不是索引查询上增量构建的。

    如果您更改设计文档,其所有索引都将重新构建,如果您有大量数据,这可能需要一些时间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多