I am trying to execute a search function in a React application.
I have a DynamoDB table:
movie_id | movie_name
1 | name a
2 | name b
I want to make a search function to search for “b” in the search input of a React application and get the result “name b” from the database.
I tried querywith CONTAINS, but didn't work, and didn't seem to be the right way to do this.
const SEARCH_KEYWORD = "b";
let params = {
TableName : 'TABLE_NAME',
KeyConditionExpression: "contains(#movie_name, :movie_name)",
ExpressionAttributeNames:{
"#movie_name": 'movie_name'
},
ExpressionAttributeValues:{
":movie_name": SEARCH_KEYWORD
}
};
documentClient.query(params, function(err, data) {
console.log(data);
});
What is the best way to create a search function in my React app with DynamoDB?
Does it make sense to run a query on a search keyword to check if the data contains a keyword value?
Ohsik source
share