3
votes

I am querying data from a database in aws dynamodb and experiencing an error message on the KeyConditionExpression.

I am querying for "dominant_temporality" and "dt". These make up my composite partition key - dt is unique for each row and my sort key.

The code I'm running:

var params = {
    TableName : "deardiary",
    KeyConditionExpression: "#d = :dominant_temporality and dt between :minDate and :maxDate",
    ExpressionAttributeNames: { 
        "#d" : "temporality"
    },
    ExpressionAttributeValues: { // the query values
        ":dominant_temporality": {S: "present"},
        ":minDate": {N: new Date("October 8, 2018").valueOf().toString()},
        ":maxDate": {N: new Date("October 9, 2018").valueOf().toString()}
    }
};
1
You need to check what your table partition key and range keys are. Is dt your range key?F_SO_K
Yes - it is what I am trying to sort the entries onEmily Chu
You can't query by sort key in keyConditionExpression. Please check my answer here : stackoverflow.com/questions/53167165/…IftekharDani

1 Answers

1
votes

Check if you are using BETWEEN on HASH which is not allowed - you can use only EQ for HASH or begins_with for range key.