【问题标题】:Azure Cosmos db Timestamp index fails saying `order-by item is excluded`Azure Cosmos db Timestamp index 失败,提示“order-by item is exclude”
【发布时间】:2019-07-10 09:25:32
【问题描述】:

我有一个包含类似于以下文档的集合:

{
  "_id": ObjectId("5cde558555555"),
  "liftId": "b227eb28a555",
  "timestamp": 1558108800000
}

我通过azure CLI 将以下索引策略应用于上述集合:

{
  "indexingMode": "consistent",
  "automatic": true,
  "includedPaths": [
    {
      "path": "/liftId/?",
      "indexes": [
        {
          "kind": "Hash",
          "dataType": "String",
          "precision": 3
        }
      ]
    },
    {
      "path": "/timestamp/?",
      "indexes": [
        {
          "kind": "Range",
          "dataType": "Number",
          "precision": -1
        }
      ]
    }
  ],
  "excludedPaths": [
    {
      "path": "/"
    }
  ]
}

但是当我尝试使用 sort 查询数据库以获取 timestamp 时,它会失败并出现以下错误:

Error: error: {
  "_t" : "OKMongoResponse",
  "ok" : 0,
  "code" : 2,
  "errmsg" : "Message: {\"Errors\":[\"The index path corresponding to the specified order-by item is excluded.\"]}\r\nActivityId:    }

【问题讨论】:

标签: azure-cosmosdb azure-cosmosdb-mongoapi


【解决方案1】:

我有类似的问题,并使用 mondo shell 创建了索引。 使用 Azure 门户获取 mongo shell 的连接字符串,并在 shell 中为时间戳创建索引。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-16
    • 1970-01-01
    • 1970-01-01
    • 2018-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多