我试图了解 Azure Cosmos DB 中物理/逻辑分区与吞吐量可用性之间的关系,但有几个问题。
参考文档:https://learn.microsoft.com/en-us/azure/cosmos-db/partitioning-overview。
根据文档,我的理解如下:
现在我的问题是:
是基于逻辑分区占用的空间,还是基于物理分区中所有逻辑分区消耗的吞吐量,或者完全是其他什么。例如,
对此的任何见解都将受到高度赞赏。
更新
根据评论,我将原始问题分为两部分。问题的第二部分可以在这里找到:Cosmos DB 中物理分区在其逻辑分区之间分割的可用吞吐量如何?。
查询数据库时如何检查@azure/cosmos sdk中的参数是否为空?
我尝试过 IS_NULL 或 IS_EMPTY,要么会破坏查询:
await container.items
.query({
query: `
SELECT * from company
WHERE company.location = @location
AND (@dateFrom IS NULL OR company.createdAt >= @dateFrom)
AND (@dateTo IS NULL OR company.createdAt < @dateTo)
ORDER BY company.createdAt DESC
`,
parameters: [
{ name: "@location", value: "Germany" },
{ name: "@dateFrom", value: new Date().setFullYear(new Date().getFullYear() - 5)},
{ name: "@dateTo", value: new Date() },
]
})
.fetchAll();
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Message: {\"errors\":[{\"severity\":\"Error\",\"location\":{\"start\":243,\"end\":245},\"code\":\"SC1001\",\"message\":\"Syntax error, incorrect syntax near 'IS'.\"}]}
Run Code Online (Sandbox Code Playgroud) 微软宣布推出Azure DocumentDB如下......
A fully-managed, highly-scalable, NoSQL document database service.
- Rich query over a schema-free JSON data model
- Transactional execution of JavaScript logic
- Scalable storage and throughput
- Tunable consistency
- Rapid development with familiar technologies
- Blazingly fast and write optimized database service
Run Code Online (Sandbox Code Playgroud)
我非常喜欢"JavaScript逻辑的事务执行".听起来像一个类似于PostgreSQL NoSQL的方法.
任何人都知道Azure DocumentDB服务的技术基础是什么?SQL Server?
我有几个DAO文件,存储在Azure DocumentDb中,现在我希望空值不会存储在DocDb中,可以通过[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]属性属性来存储 .但我不想把这个属性放在每个财产上.
问题是,没有任何方法可以设置JsonSerializerSettingsAzure DocumentDb API使用的Json序列化程序.
对我来说,似乎是使用JsonConverter类的属性,并创建一个自定义JsonConverter类,它将使用标准序列化但更改序列化设置.
这是转换器:
public class CommonJsonConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return true;
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var token = JObject.ReadFrom(reader);
return token.ToObject(objectType, serializer);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
serializer.NullValueHandling = NullValueHandling.Ignore;
var jo = JObject.FromObject(value, serializer);
jo.WriteTo(writer);
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到了WriteJson这样的例外:
Newtonsoft.Json.dll发生了'Newtonsoft.Json.JsonSerializationException'类型的第一次机会异常
附加信息:使用"Infrastructure.Dao.Contacts.PersonDao"类型检测到的自引用循环.路径''.
我试图将WriteJson函数更改为:
public override …Run Code Online (Sandbox Code Playgroud) 如何查询包含" - "符号的属性.
具体来说,我想执行此查询:
SELECT * FROM c.inside.abs-humid
Run Code Online (Sandbox Code Playgroud)
但这给了我一个错误.
在没有破折号的情况下查询属性工作得很好,我该怎么做?
我正在开发一个全球应用程序,其中大多数搜索基于地理数据(最近的记录给定坐标)和日期范围.
因此,基本上可能是AirBnb,Booking等应用程序的主要搜索.
考虑到这些上下文,我应该在DocumentDB分区集合中选择哪个分区键?
谢谢!
更新:就像我告诉马蒂亚斯(见答案),我和我的朋友,我们正在考虑像国家这样的事情.该应用程序是关于搜索.另一件重要的事情是我们有约会.大量的约会.由于我们是DDB的新手,我们的问题是:" 如果我们选择国家作为分区密钥,我们的查询必须在不同国家/地区内搜索,会发生什么? ".即在国家边界附近搜索georadius.
我在azure documentDB平台的c#中开发.我尝试在我的应用程序中实现分页体系结构.我的代码:
var userQuery = _client.CreateDocumentQuery<User>(
_uriUsersCollection, queryStr, options).AsDocumentQuery();
Run Code Online (Sandbox Code Playgroud)
我的代码在AsDocumentQuery()函数上显示错误(它不被识别为IQueryable方法的一部分(我在互联网上看到该函数识别的几个例子).所以当我尝试激活查询时.ExecuteNextAsync它不存在.我使用Microsoft.Azure.Documents.Client dll版本1.11.0.0.感谢您的帮助MAK
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.ExperimentIdentifier = 'prod'
AND c.Param = 'banana'
AND Contains(c.SampleDateTime, '20171029')
ORDER BY c.SampleDateTime DESC
Run Code Online (Sandbox Code Playgroud)
However, I get the exception:
Order-by item requires a range index to be defined on the corresponding index path.
没有链接可以帮助您解决该错误,并且从该错误消息中我也无法幸免。
这是什么意思,为什么我的查询失败,该如何解决?
PS该_ts属性对我不利,因为我不想在插入记录时进行订购。
我正在构建一个Azure Http触发的C#函数,其输出绑定到Cosmos DB.我的函数定义是这样的:
[FunctionName("HttpTriggerFunction")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = "myroute")]HttpRequestMessage req,
[DocumentDB("database", "collection", ConnectionStringSetting = "CosmosDBConnection")] IAsyncCollector<dynamic> document,
TraceWriter log)
Run Code Online (Sandbox Code Playgroud)
这很好用.
但是,我希望能够在DocumentDB属性中配置数据库和集合名称,但是如果我尝试这样的话:
[DocumentDB(ConfigurationManager.AppSettings["DatabaseName"], ConfigurationManager.AppSettings["CollectionName"], ConnectionStringSetting = "CosmosDBConnection")]
Run Code Online (Sandbox Code Playgroud)
然后Visual Studio给我一个编译错误:
CS0182属性参数必须是属性参数类型的常量表达式,typeof表达式或数组创建表达式
有没有办法配置这些DocumentDB属性参数?
嗨有没有办法在cosmosdb中实现dateiff?
Select Datediff(day,c.datea, c.dateb) from c
Run Code Online (Sandbox Code Playgroud)
显然,约会者不是一个受支持的关键词,我无法找到一个等价物.
提前致谢
azure-cosmosdb ×10
azure ×9
c# ×3
nosql ×3
database ×1
geospatial ×1
json ×1
json.net ×1
node.js ×1