【发布时间】:2020-04-24 12:44:54
【问题描述】:
我有以下疑问:
{
"selector":{
"lastname":{
"$regex":"(?i)[cç][oòóôõöø]"
},
"firstname":{
"$gt":null
},
"type":"person",
"owner":{
"$in":["admin"]
}
},"sort":["lastname","firstname"]
}
并尝试了许多索引:
{
"type": "json",
"def": {
"fields": [
{
"lastname": "asc"
}
]
}
}
{
"type": "json",
"def": {
"fields": [
{
"lastname": "asc"
},
{
"firstname": "asc"
}
]
}
}
{
"type": "json",
"def": {
"fields": [
{
"lastname": "asc"
},
{
"firstname": "asc"
},
{
"type": "asc"
},
{
"owner": "asc"
}
]
}
}
但没有一个有效。仅供参考,我使用的是 CouchDB 2.1.0。
我还尝试将"sort":["lastname","firstname","type","owner"] 添加到查询中。仍然收到警告:no matching index found, create an index to optimize query time
我做错了什么?
编辑:我将 PouchDB 直接用于我的 CouchDB 服务器(不同步),如果这可以帮助...
【问题讨论】:
-
我的猜测是,排序中的第一个元素必须在选择器中并使用使用索引的运算符(正则表达式不使用)
-
@AlexisCôté 我试图将类型放在选择器的首位,但仍然收到警告。我还在排序中添加了类型,也没有帮助......
标签: couchdb pouchdb couchdb-mango