rbo*_*hac 1 azure azure-cosmosdb azure-cosmosdb-sqlapi
执行以下查询时,我收到一个错误
select * from c order by c.Agent.LastStateChangeUnixTime desc,c.Priority asc
order by 查询没有相应的复合索引可以从中提供服务
我的综合指数错了吗?还是我错过了其他东西?
我的索引设置是:
{
"indexingMode": "consistent",
"automatic": true,
"includedPaths": [
{
"path": "/*"
}
],
"excludedPaths": [
{
"path": "/\"_etag\"/?"
}
],
"compositeIndexes": [
[
{
"path": "/Priority",
"order": "descending"
},
{
"path": "/Agent/LastStateChangeUnixTime",
"order": "ascending"
}
]
]
}
Run Code Online (Sandbox Code Playgroud)
示例对象:
{
"Agent": {
"TenantId": 999999,
"PrimaryState": "Null",
"PendingState": "Null",
"LastStateChange": "2020-01-18T05:48:11.5397269+00:00",
"LastStateChangeUnixTime": 1579326491,
"Notes": null,
"AgentId": 123,
"id": "agent-123"
},
"AgentId": 123,
"SkillName": "English",
"id": "SkillName123",
"Priority": 10,
"_rid": "SVIMANKqJboCAAAAAAAAAA==",
"_self": "dbs/SVIMAA==/colls/SVIMANKqJbo=/docs/SVIMANKqJboCAAAAAAAAAA==/",
"_etag": "\"2200819a-0000-0700-0000-5e229c1d0000\"",
"_attachments": "attachments/",
"_ts": 1579326493
}
Run Code Online (Sandbox Code Playgroud)
是的,您的复合索引对于此查询不正确。它们出现的顺序很重要,因此 WHERE 子句需要匹配顺序。
将以下内容更改或添加到您的复合索引中。
"compositeIndexes": [
[
{
"path": "/Agent/LastStateChangeUnixTime",
"order": "descending"
},
{
"path": "/Priority",
"order": "ascending"
}
]
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2193 次 |
| 最近记录: |