I am trying to build Filter Expression in query for searching data in dynamodb.
var params = {
TableName: "ContactsTable",
ExpressionAttributeNames: {
"#lastName": "LastName",
"#firstName": "FirstName",
"#contactType": "ContactType"
},
FilterExpression: "contains(#lastName, :searchedName) or contains(#firstName, :searchedName)",
ExpressionAttributeValues: {
":companyContactType": event.query.companyContactType,
":searchedName": event.query.searchedValue
},
KeyConditionExpression: "#contactType = :companyContactType"
};
Users generally search for LastName, FirstName (they append comma to LastName as a common search pattern). However data is stored in separate attributes named LastName and FirstName so that they can search by that as well.
Is there a way by which I can dynamically concatenate these two fields something like contains(#lastName<append comma>#firstName, :searchedName)
?