您可以通过DynamoDB中的GSI范围进行查询

时间:2016-03-09 00:48:50

标签: amazon-web-services amazon-dynamodb nosql

假设我在DynamoDB中有一个用户和图像表。

users table
userId (hash) name email 

images table
imagesId (hash) userId filename

如果我想获取单个userId的所有图像,我应该如何设置范围或GSI?图像表是否应该是具有imageId(哈希)和userId(范围)的复合键,并按范围搜索(如果可能)?或者userId(是一个GSI)和查询只是userId?

2 个答案:

答案 0 :(得分:1)

您无法仅使用DynamoDB中的范围键进行查询。

除非您希望userId表中的查询结果按userId排序,否则无法将其用作范围键。如果要使用查询从images表中检索具有特定userId的所有图像,则需要在std::complex<double> res = cblas_zdotc(fpowa_d.size(), fpowa_d.data(), 1, fpowa_p.data(), 1); func.cc:42:93: error: ‘cblas_zdotc’ was not declared in this scope 上使用GSI。

答案 1 :(得分:1)

您的图片表格中的add a GSI似乎可以使用您的表格的反向键架构:

  • hash key - userId
  • range key - imagesId
  • filename - 附加财产

然后,您可以使用userId查询此GSI,以获取所有关联的imagesId

相关问题