【发布时间】:2019-08-15 18:30:46
【问题描述】:
我对 DynamoDB 比较陌生,目前我正在使用 Node.js 尝试 AWS 示例。我对本教程有疑问:AWS tutorial to load a movie DB and query data.
我想搜索指定演员出演的电影。 例如,“丹尼尔·布鲁尔”和“奥利维亚·王尔德”。 另一个例子,“丹尼尔布鲁尔”或“休杰克曼”。 另外,如果可能的话,我想搜索模糊(例如“??? Bruhl”)。
需要拆分表还是定义过滤器?
样本数据:
{ "year" : 2013, "title" : "Turn It Down, Or Else!", "info" : { "directors" : [ "Alice Smith", "Bob Jones" ], "release_date" : "2013-01-18T00:00:00Z", "rating" : 6.2, "genres" : [ "Comedy", "Drama" ], "image_url" : "http://ia.media-imdb.com/images/N/O9ERWAU7FS797AJ7LU8HN09AMUP908RLlo5JF90EWR7LJKQ7@@._V1_SX400_.jpg", "plot" : "A rock band plays their music at high volumes, annoying the neighbors.", "rank" : 11, "running_time_secs" : 5215, "actors" : [ "David Matthewman", "Ann Thomas", "Jonathan G. Neff" ] } }
架构:
TableName : "Movies", KeySchema: [ { AttributeName: "year", KeyType: "HASH"}, //Partition key { AttributeName: "title", KeyType: "RANGE" } //Sort key ], AttributeDefinitions: [ { AttributeName: "year", AttributeType: "N" }, { AttributeName: "title", AttributeType: "S" } ], ProvisionedThroughput: { ReadCapacityUnits: 10, WriteCapacityUnits: 10 }
表格填满:
allMovies.forEach(function(movie) { var params = { TableName: "Movies", Item: { "year": movie.year, "title": movie.title, "info": movie.info } }; docClient.put(params, function(err, data) { if (err) { console.error("Unable to add movie", movie.title, ". Error JSON:", JSON.stringify(err, null, 2)); } else { console.log("PutItem succeeded:", movie.title); } });
【问题讨论】:
标签: amazon-dynamodb