Azure CosmosDb: Order-by item requires a range index

前端 未结 1 1113
既然无缘
既然无缘 2021-01-27 09:28

I\'m performing a simple query via the Azure Portal \"Query Explorer\".

Here is my query:

SELECT * FROM c
WHERE c.DataType = \'Fruit\' 
AND c.ExperimentI         


        
1条回答
  •  北海茫月
    2021-01-27 09:49

    ORDER BY is served directly from the index and thus it requires the order by item to be Range indexed (as opposed to Hash indexed).

    While you could only index the order-by item as range (for both numbers and string), my advice is to index all paths as range with precision of -1.

    Basically, you'd need to update the indexing policy of your collection to be something like this:

        {
            "automatic": true,
            "indexingMode": "consistent",
            "includedPaths": [
                {
                    "path": "/", 
                    "indexes": [ 
                        { "kind": "Range", "dataType": "Number", "precision": -1 }, 
                        { "kind": "Range", "dataType": "String", "precision": -1 }
                    ]
                }
            ]
        }
    

    0 讨论(0)
提交回复
热议问题