如何在 CouchDB 中使用 CURL 或 HTTP API 创建搜索索引?

How to create a search index with CURL or HTTP API in CouchDB?

如何创建与此类似的设计:

{
   "_id": "_design/foo",
   "_rev": "1-166900c56b2e87d91bb48dcf890c84ed",
   "fulltext": {
       "by_title": {
           "index": "function(doc) { var ret=new Document(); ret.add(doc.title); return ret }"
       }
   }
}

摘自本教程: BlogPost

我已经重新编译了我的 CouchDB 以允许 couchdb-lucene。 github couchdb-lucene

我遇到的问题是我找不到任何合适的例子来尝试插入没有 UI 的设计,它只允许设计视图,而不是搜索索引

可以像创建常规文档一样创建设计文档,因此您可以使用 HTTP API for documents

您可以将设计保存在一个文件中,比如 'yourdesign.json',然后使用这样的命令上传它:

curl -H 'Content-Type: application/json' -X PUT http://127.0.0.1:5984/yourdb/_design/foo -d @yourdesign.json