【问题标题】:Using $or selector, There is no index available for this selector使用 $or 选择器,此选择器没有可用的索引
【发布时间】:2016-04-25 14:54:22
【问题描述】:

我想找回

  • 包含_id1 的文档

  • 带有value === 13anotherValue === 56 的文档

错误:

此选择器没有可用的索引。

这是我的查询:

{
  "selector": {
      "$or": [
          {
              "_id": "1"
          },
          {
              "value": "13",
              "anotherValue": "56"
          }
       ]
   }
}

索引设置:

Your available Indexes:
special: _id
json: value, anotherValue
json: _id, value, anotherValue

【问题讨论】:

    标签: indexing couchdb cloudant couchdb-mango


    【解决方案1】:

    对于这个查询,您需要添加一个选择器来获取所有 ID,如下所示:

    {
        "selector": {
            "_id": {"$gt":null},
            "$or": [
                {
                    "_id": "1"
                },
                {
                    "value": "13",
                    "anotherValue": "56"
                }
            ]
        }
    }
    

    您可以在这里了解更多信息:

    https://cloudant.com/blog/mango-json-vs-text-indexes/

    还有这个 SO 帖子:

    index and query items in an array with mango query for cloudant and couchdb 2.0

    或者,您可以在所有字段上添加文本索引:

    {
        "index": {},
        "type": "text"
    }
    

    然后你原来的选择器应该可以工作了。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-16
    • 2010-09-14
    • 1970-01-01
    相关资源
    最近更新 更多