knu2xs knu2xs - 11 months ago 185
Javascript Question

With AWS DocumentClient less than on secondary index query - "Query key condition not supported"

The function below, it should be simple, right? This is what I thought as well. Still, for the life of me, I cannot figure out why I keep getting an error informing me of a, "

," with an error informing me, "
Query key condition not supported

const getUpdated = (refreshDatetime, callback) => {

refreshDatetime = parseInt(refreshDatetime);

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

Just to make sure I am not doing anything else incredibly stupid (a distinct possibility as well), here is the snippet I am using to test.

const refreshDatetime = Date.parse('01 Jan 2015');
getUpdated(refreshDatetime, (error, response) => {

Insight and ideas are welcomed and greatly appreciated as writing code, even this little code, definitely is not my strongest talent!

Update: To add additional detail, my hash key is
, and my partition key associated with my secondary index is

enter image description here

Answer Source

Dynamodb does not allow to use any other condition except "=" on Hash/partition key.

You can optionally use other expressions for Range/sort key but not for Hash key.

refer: Documentation link

Another post with similar problem

Hope that helps.