且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我的收藏的Azure Cosmos DB索引策略

更新时间:2023-02-14 12:34:05

您好,Amjathkhan,

Hi Amjathkhan,

请在上阅读 索引路径.我将在您的第二个Json示例中使用类似下面的内容,但是取决于如果您的Json和分区集合中有数组等. 

Please read-up on Index Paths. I would use something like the below with your second Json example but, depends  if you have arrays in your Json and partitioned collections, etc. 

/prop/*

Index path for all paths under the specified label. Works with the following queries

SELECT FROM collection c WHERE c.prop = "value"
SELECT FROM collection c WHERE c.prop.subprop > 5
SELECT FROM collection c WHERE c.prop.subprop.nextprop = "value"
SELECT FROM collection c ORDER BY c.prop

/props/[]/subprop/?

/props/[]/subprop/?

Index path required to serve iteration and JOIN queries against arrays of objects like [{subprop: "a"}, {subprop: "b"}]:

SELECT tag FROM tag IN collection.props WHERE tag.subprop = "value"
SELECT tag FROM collection c JOIN tag IN c.props WHERE tag.subprop = "value"