如何在名称为"a%"的couchdb中编写通配符搜索查询 [英] How to write wildcard search query in couchdb where name like 'a%'
问题描述
如何在沙发数据库中编写通配符搜索?我想在sql中写与"LIKE%"相同的查询.请为此提供帮助.
How can I write wildcard search in couchdb? I want to write query same as 'LIKE %' in sql.please help me for this.
{
"name":"arun",
"surname":"mr"
}
{
"name":"balu",
"surname":"tp"
}
我需要列出所有以'a'开头的名称.
I need to list all names that start with 'a'.
谢谢..
推荐答案
在beddb中,您可以通过查询字符串范围.
In couchdb you can query over string ranges.
首先,您需要一个将所有名称都作为键发出的视图
First you need to have a view that emits all the names as keys
function(doc){
if(doc.name)
emit(doc.name,null);
}
然后您可以使用
http://localhost:5984/your-db-name/_design/your-ddoc-name/_view/your-view-name?startkey="a"&endkey="a\ufff0"
,它将为您提供所有以a
开头的名称.
http://localhost:5984/your-db-name/_design/your-ddoc-name/_view/your-view-name?startkey="a"&endkey="a\ufff0"
which will give you all the names starting with a
.
'\ uff0'只是一个高价值的Unicode字符,而不是一个特定的字符,它将在beddb中执行魔术.
'\uff0' is just a high value unicode character, not a specific character that will perform magic tricks in couchdb.
这篇关于如何在名称为"a%"的couchdb中编写通配符搜索查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!