在 couchdb 视图中查询键是否包含字符串
Query a couchdb view on whether the key contains the string
我正在使用执行以下操作的节点 couchdb api
couch.get(dbName, viewURL, {
"key" : "Extra. This is what I want to search for. Extra."
}).then(function(data, status, headers){
if(data.data.rows[0] === undefined){
// nothing exists in the view by this key
}
else console.log(data.data.rows[0]) // gives first JSON element in db
});
我的问题是是否有一种方法可以查询它,以便密钥只需要包含 "This is what I want to search for." 而不需要关心额外的信息。我意识到这不是应该使用 key:value 对的正确方法,但我需要它来解决问题。
我建议使用 ElasticSearch 进行全文搜索。但如果你坚持在 CouchDB 中实现它,你可以尝试其中的任何一个:
- 获取您应用中的所有文档并通过您的代码进行比较(类似于动态视图)
- 试试这个 CouchDB 插件:https://github.com/rnewson/couchdb-lucene
我正在使用执行以下操作的节点 couchdb api
couch.get(dbName, viewURL, {
"key" : "Extra. This is what I want to search for. Extra."
}).then(function(data, status, headers){
if(data.data.rows[0] === undefined){
// nothing exists in the view by this key
}
else console.log(data.data.rows[0]) // gives first JSON element in db
});
我的问题是是否有一种方法可以查询它,以便密钥只需要包含 "This is what I want to search for." 而不需要关心额外的信息。我意识到这不是应该使用 key:value 对的正确方法,但我需要它来解决问题。
我建议使用 ElasticSearch 进行全文搜索。但如果你坚持在 CouchDB 中实现它,你可以尝试其中的任何一个:
- 获取您应用中的所有文档并通过您的代码进行比较(类似于动态视图)
- 试试这个 CouchDB 插件:https://github.com/rnewson/couchdb-lucene