azure-cosmosdb

Change Feed Consistency Level

淺唱寂寞╮ 提交于 2021-01-28 14:30:23
问题 Assuming we do not have strong consistency set, when using azure functions change feed are we guaranteed to get the latest document when querying against the same partition? Also, are all queries issues from within the change feed guaranteed the latest records since the change feed runs on the write region? Thanks! 回答1: You can read changefeed from any read region. Check the pull request https://github.com/Azure/azure-webjobs-sdk-extensions/pull/508. This code will be part of function soon.

Azure CosmosDB Query Explorer vs Data Explorer

久未见 提交于 2021-01-28 12:26:01
问题 I'm running the same query against my CosmosDB instance (using SQL API): SELECT c.partition, COUNT(1) AS total FROM c WHERE c.system = "SF" GROUP BY c.partition I'm a bit surprised that I'm getting expected results from Data Explorer while under Query Explorer tab I'm getting 400 Bad Request with below message: {"code":400,"body":"{\"code\":\"BadRequest\",\"message\":\"Message: {\\"Errors\\":[\\"Cross partition query only supports 'VALUE ' for aggregates.\\"]}\r\nActivityId: d8523615-c2ff

Why does including partition key in WHERE clause to Cosmos SQL API query increase consumed RUs for some queries?

守給你的承諾、 提交于 2021-01-28 09:51:03
问题 I would like to optimise my Azure Cosmos DB SQL API queries for consumed RUs (in part in order to reduce the frequency of 429 responses). Specifically I thought that including the partition key in WHERE clauses would decrease consumed RUs (e.g. I read https://docs.microsoft.com/en-us/azure/cosmos-db/optimize-cost-queries and https://docs.microsoft.com/en-us/azure/cosmos-db/partitioning-overview which made me think this). However, when I run SELECT TOP 1 * FROM c WHERE c.Field = "some value"

Avoid getting back DocumentDb system properties

纵然是瞬间 提交于 2021-01-28 09:11:01
问题 I have a query which returns one document Select * from root Above query also returns extra system properties like _ts, _self, _etag etc. I do not want my query to return those extra properties. And I want * as I do not want to specify columns to select. I am running this query in sproc. Any better way to not return system properties? 回答1: I don't know of any way to do that. It will not take up a significant amount of resources to get them and you can always just ignore them. Alternatively,

How do I define unique keys involving properties in embedded arrays in Azure Cosmos DB?

心已入冬 提交于 2021-01-28 08:25:45
问题 In Azure Cosmos DB, there is support for unique keys. Each unique key is defined as a set of paths representing values in the stored documents. An example of such a path would be /contact/firstName . It's not clear from the official docs (in fact it's not mentioned at all) how those paths apply down through embedded arrays within the document, or how unique key semantics apply when paths navigate into nested documents with a cardinality of more than one. For example, let's say I have a

Avoid getting back DocumentDb system properties

主宰稳场 提交于 2021-01-28 07:51:25
问题 I have a query which returns one document Select * from root Above query also returns extra system properties like _ts, _self, _etag etc. I do not want my query to return those extra properties. And I want * as I do not want to specify columns to select. I am running this query in sproc. Any better way to not return system properties? 回答1: I don't know of any way to do that. It will not take up a significant amount of resources to get them and you can always just ignore them. Alternatively,

How to get more than 100 query results with Azure DocumentDB REST API

陌路散爱 提交于 2021-01-28 07:31:55
问题 I am following a sample for Azure DocumentDB below. In the sample, C# code queries for documents in the DocumentDB. https://github.com/Azure/azure-documentdb-dotnet/blob/master/samples/rest-from-.net/Program.cs Line 182: var qry = new SqlQuerySpec { query = "SELECT * FROM root" }; var r = client.PostWithNoCharSetAsync(new Uri(baseUri, resourceLink), qry).Result; The problem is the result 'r' only contains the first 100 documents. If I use the Client SDK, I can get more than 100. I tried using

How to split into Sub Documents with Nesting separator?

蹲街弑〆低调 提交于 2021-01-28 05:27:52
问题 I am migrating data from SQL to COSMOS DB through Azure cosmos DB Data Migration Tool Can someone please help help to migrate data in Sub-Documents, how to specify in nesting separator SELECT TOP 5 P.ProjectDocumentId, P.ProjectId, PU.UpdatedByFullName FROM [Docs].[ProjectDocuments] P INNER JOIN [Docs].[ProjectDocumentUpdate] PU ON P.ProjectDocumentID = PU.ProjectDocumentID WHERE P.ProjectDocumentId = '7DA0011B-7105-4B6C-AF13-12B5AC50B608' Result: Expected Document in Cosmos DB: {

Can I check for uniqueness and write a document in a Cosmos DB stored procedure

社会主义新天地 提交于 2021-01-28 03:27:27
问题 I have a Cosmos DB stored procedure that creates a new document if it doesn't already exist and returns the existing or the new document. The procedure may be called from different processes. Can I be sure that the document is only created once even if several clients are trying to create it at the same time? function createIfNotExists(param1, param2) { var collection = getContext().getCollection(); // Query documents and take 1st item. var query = 'SELECT * FROM c WHERE c.Param1="' + param1

Cosmos DB : cross partition query can not be directly served by the gateway

谁说我不能喝 提交于 2021-01-28 00:10:33
问题 Any idea why when I execute the query below in Cosmos DB using the rest api I get the error below? The same query without the order by works fine... I have set the header "x-ms-documentdb-query-enablecrosspartition: True" in both cases and I am using PHP to make the requests. MULTI PARTITION QUERY THAT WORKS: SELECT c.id, c.name, c.age FROM c where c.age = 30 MULTI PARTITION QUERY WITH ERROR: SELECT c.id, c.name, c.age FROM c where c.age = 30 order by c.age asc ERROR: Client error: POST https