"Order by" query on Document DB suddenly stopped working on my development environment and is working fine without "Order by"
Here is the query which is not working (Use to work till yesterday and till yesterday it use to return me 70+ documents and now its returning null results(Empty array)):
SELECT * FROM c WHERE c.Category = 'test' ORDER BY c.StartDate DESC
Here is the query which is working(Currently its returning 70+ results and it use to return the same yesterday (which is not the case with the above query which is not working )):
SELECT * FROM c WHERE c.Category = 'test'
Did someone face the similar problem? What can be the solution for this?
I found the solution to the problem. As per the documentations:
https://learn.microsoft.com/en-us/azure/cosmos-db/indexing-policies
It clearly says
"The default indexing policy sets "kind=Hash, precision=3" by default. If it is changed into "kind=Range, precision=-1". Order by on string datatype works as expected."
And i found the solution here:
https://github.com/Azure/azure-documentdb-dotnet/issues/65
Here are few more links that help you know more about Document DB Indexing
https://azure.microsoft.com/en-us/blog/order-query-results-with-azure-documentdb/
https://azure.microsoft.com/en-us/blog/update-your-documentdb-indexing-policies-online/
So i have deleted my old collection and created a new one with precision "-1".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With