"message": "Query key condition not supported", in node js using begins_with()

306 Views Asked by At

I am getting the following error while using the following snippet of code. Appreciate your early response.

Error:

 "message": "Query key condition not supported",
    "code": "ValidationException",

Code Snippet:

var params ={ TableName:"gs_sub_service_lv1",
             KeyConditionExpression:"ss_lv1_status = :status_value and 
                          begins_with(ss_lv1_id, :ss_lv1_id)",
                   ExpressionAttributeValues: {
                         ":status_value":  1,
                         ":ss_lv1_id": "04"
                    }
             }
              docClient.query(params, function(err,ss_data){
                 
                 if(err){
                     console.log("ERROR::",err)
                        callback(null,{status:err})   
                 }
                 else{
                     console.log("RESULT",ss_data)
                 callback(null,{Result:ss_data.Items})   

                 }
             })
1

There are 1 best solutions below

0
On

I resolved the issue. The problem is we need to use the docClient.scan(params, function(err,ss_data) and also use the FilterExpression instead of KeyConditionExpression .

Thanks