我有一个员工dto,部门为partitionKey。
我尝试了什么:
List<Document> documentList = documentClient.queryDocuments(getCollection().getSelfLink(),"SELECT * FROM root r WHERE r.partitionKey ='" + partitionKey+"'", null).getQueryIterable().toList();
我最终从java api获得 IllegalStateException 状态异常,并且查询导出器也没有提供任何输出。任何帮助都非常值得赞赏。
答案 0 :(得分:4)
部分答案:
如果Partition Key
属性的名称为department
,请将您的查询更改为:
List<Document> documentList =
documentClient.queryDocuments(
getCollection().getSelfLink(),
"SELECT * FROM root r WHERE r.department ='" +
partitionKey + "'", null).getQueryIterable().toList();
答案 1 :(得分:0)
您还可以通过提供收集链接
来实现相同的目标List<Document> documentList = documentClient.queryDocuments("/dbs/<yourdbname>/colls/<collectionname>","SELECT * FROM root r WHERE r.department ='" + partitionKey+"'", null).getQueryIterable().toList();