【问题标题】:With AWS DocumentClient less than on secondary index query - "Query key condition not supported"AWS DocumentClient 小于二级索引查询 - “不支持查询键条件”
【发布时间】:2017-04-01 20:44:04
【问题描述】:

下面的函数,应该很简单吧?这也是我的想法。尽管如此,对于我的生活,我无法弄清楚为什么我不断收到错误消息,通知我“ValidationException”,错误消息通知我“Query key condition not supported”。

const getUpdated = (refreshDatetime, callback) => {

  refreshDatetime = parseInt(refreshDatetime);

  docClient.query({
    TableName: 'aw-reach',
    IndexName: 'updateDatetime-index',
    KeyConditionExpression: ':refreshDatetime < updateDatetime',
    ExpressionAttributeValues: {
      ':refreshDatetime': refreshDatetime,
    }
  }, (error, data) => {
    if (error) callback(error, null);
    callback(null, data.Items);
  });
};

只是为了确保我没有做任何其他非常愚蠢的事情(也很可能),这是我用来测试的 sn-p。

const refreshDatetime = Date.parse('01 Jan 2015');
getUpdated(refreshDatetime, (error, response) => {
  console.log(JSON.stringify(response));
});

在编写代码时,欢迎并非常感谢洞察力和想法,即使是这个小代码,也绝对不是我的最强天赋!

更新:要添加更多详细信息,我的哈希键是 reachId,与二级索引关联的分区键是 updateDatetime

【问题讨论】:

  • refreshDatetime 是你的哈希键吗?
  • 是与索引关联的分区键。

标签: javascript node.js amazon-web-services amazon-dynamodb aws-lambda


【解决方案1】:

Dynamodb 不允许在哈希/分区键上使用除“=”之外的任何其他条件。

您可以选择将其他表达式用于范围/排序键,但不能用于哈希键。

参考:Documentation link

Another post with similar problem

希望对您有所帮助。

【讨论】:

  • 非常感谢您的解释和文档链接。尽管我一直在尝试浏览文档,但我往往会迷失在可以找到同一主题文档的所有不同地方之间。谢谢你帮我大海捞针!
猜你喜欢
  • 1970-01-01
  • 2017-01-07
  • 1970-01-01
  • 2015-10-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多