简体   繁体   English

NoSql和按列表查询

[英]NoSql and query by list

I have a DynamoDB database with roughly 100.000 items in. The items are mostly a flat, but they do contain a list of categories. 我有一个DynamoDB数据库,其中包含大约100.000个项目。这些项目大多是平面的,但它们确实包含类别列表。

{
  "name": "Protine shaker",
  "categories": [
     "Sport",
     "Kitchen"
  ];
}

I want to be able to find all items that for an example is a member of the category "Sport", but as it is a list can i not index it. 我希望能够找到所有示例中属于“运动”类别的项,但由于它是一个列表,因此我无法对其进行索引。 My only option with a pure DyanmoDB solution would therefore be to scan the whole table, which is something that can be expensive if done often. 因此,使用纯DyanmoDB解决方案的唯一选择就是扫描整个表,如果经常进行,这可能会很昂贵。

I where thinking that i could have a SQL database besides the DynamoDB that just contained the category mapping, or have another DynamoDB tales with an object for each category containing a list of items in that category. 我想到的是,除了可以包含类别映射的DynamoDB之外,我还可以拥有一个SQL数据库,或者为每个类别的对象创建另一个DynamoDB故事,其中包含该类别中的项目列表。

What is the normal/common solutions to such a problem when working with DynamoDB? 使用DynamoDB时,解决此问题的正常/常见解决方案是什么? I am guesses that this must be a common problem to have. 我猜想这肯定是一个普遍的问题。

You can integrate DynamoDB with ElasticSearch which can provide more options to query for data that is not supported by DynamoDB out of the box. 您可以将DynamoDB与ElasticSearch集成在一起,后者可以提供更多选项来查询DynamoDB不支持的数据。 Just create indices in ElasticSearch and perform your queries there. 只需在ElasticSearch中创建索引并在其中执行查询即可。

Where to get started: https://aws.amazon.com/about-aws/whats-new/2015/08/amazon-dynamodb-elasticsearch-integration/ 从哪里开始: https//aws.amazon.com/about-aws/whats-new/2015/08/amazon-dynamodb-elasticsearch-integration/

Having a SQL database is not a good solution because you will have to keep the information in sync in two different data-stores by yourself. 拥有SQL数据库不是一个好的解决方案,因为您必须自己将信息同步在两个不同的数据存储中。 Looks like an operation pain for maintenance. 看起来像是维护的操作难题。

Having multiple DynamoDB tables per Category is not scalable and even here you would have multiple DynamoDB tables to update in a "transaction" which is possible but comes with degraded performance or you could have AWS lambda write to relevant Category table based on DynamoDB update stream. 每个类别具有多个DynamoDB表是不可扩展的,即使在这里,您也可以通过“事务”来更新多个DynamoDB表,这是可能的,但是会降低性能,或者您可以让AWS Lambda根据DynamoDB更新流写入相关的Category表。 But still it is better to avoid for the sake of scalability. 但是,为了可伸缩性,最好还是避免。 You would have to create a new table every time a new Category is introduced. 每次引入新类别时,您都必须创建一个新表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM