Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure cosmosdb 如何通过SDK或Select查询在CosmosBD中使用分区键_Azure Cosmosdb - Fatal编程技术网

Azure cosmosdb 如何通过SDK或Select查询在CosmosBD中使用分区键

Azure cosmosdb 如何通过SDK或Select查询在CosmosBD中使用分区键,azure-cosmosdb,Azure Cosmosdb,下面是我的json示例 { "servletname": "cofaxEmail", "servlet-class": "org.cofax.cds.EmailServlet", "init-param": { "mailHost": "mail1", "mail

下面是我的json示例

    {         
      "servletname": "cofaxEmail",
      "servlet-class": "org.cofax.cds.EmailServlet",
      "init-param": {
      "mailHost": "mail1",
      "mailHostOverride": "mail2"    
    }
我选择servletname作为我的主键,因为我会在每个请求中收到它,再加上1000个服务器名,这可能是最好的PK

我的问题是,让分区键为我工作

我必须像下面那样单独指定分区键选项吗

ItemResponse<ServerDto> ServerDtoResponse = await this.container.ReadItemAsync<ServerDto>(bocServerDto.mailHost, new PartitionKey(bocServerDto.servletname));
问题的关键是:通过在select查询的where条件下传递partitionKey对象,是否足以利用分区键特性


感谢您为分区键传入的任何crud操作。例如,在一个点上读取

ItemResponse<ServerDto> ServerDtoResponse = await this.container.ReadItemAsync<ServerDto>(bocServerDto.mailHost, new PartitionKey("cofaxEmail"));
对于查询,可以在queryRequest选项中传递它,也可以在查询中将其用作第一个筛选谓词。是使用queryRequest选项的示例

谢谢

ItemResponse<ServerDto> ServerDtoResponse = await this.container.ReadItemAsync<ServerDto>(bocServerDto.mailHost, new PartitionKey("cofaxEmail"));