如何搜索DynamoDB并提供最佳结果,不受1 MB限制的影响。

huangapple go评论135阅读模式
英文:

How to search through dynamodb and provide best result irrespective of 1 mb limit

问题

我一直在一个使用DynamoDB存储帖子列表的项目上工作。

以下是我的目标:

  1. 能够发布和更新帖子(已完成)
  2. 用户能够搜索帖子列表(已完成)

问题出在扫描操作的1MB最大限制上。

当用户进行搜索时,我执行扫描操作以获取所有帖子,然后使用算法对每个帖子的相关性进行评分,然后进行排序。

最初,我以为这就足够了... 我只需添加分页功能,以便用户可以看到下一个1MB的数据。

问题在于:

假设第一个1MB的数据中有帖子的得分分别为78%,56%,12%,以及一些1或2%。

好的,这个方案可行,一切都可以显示。

然后用户点击下一页。

如果下一个1MB的数据中有一个帖子的得分是80%或90%怎么办?

我该如何检查这个情况?我需要将90%的帖子排在前面,但它在下一个1MB的数据中,只有在用户点击下一页后才能检查(如果所有好的结果都在最后一页,那将很糟糕)。

我听说过类似batchGetAllItems之类的东西...但我喜欢1MB的限制,因为它可以加快速度。

我该如何处理这个问题?DynamoDB中是否有一些搜索功能我可以使用?

英文:

I have been working on a project that uses dynamo db to store a list of posts.

Here are my goals:
Ability to post and update a post (done)
Ability for a user to search through a list of posts (done)

The problem lies in the 1 mb max for scan operations

When a user searches, I do a scan operation to grab every post, then i use an algorithm to rate the relevance of each post, then I sort it.

Originally, I thought that this would be enough… I just have to add a pagination feature so that people can see the next mb of data.

Here is the problem:

Let’s say that the first mb of data has posts with the scores of 78%, 56%, 12%, and a couple 1 or 2%.

Okay. This works, everything is displayed.

Then the user clicks on the next page.

What if the next mb of data has a post with 80% or 90%?

How would I check this? I need the 90% to be at the top, except it is in the next mb of data, and can’t be checked until the user clicks the next page (and it would be pretty bad if all the good results were on the last page)

I’ve heard of things like batchGetAllItems of something like that.. but I am a fan of the 1 mb limit as it speeds things up.

How would I go about this? Is there some searching feature within dynamodb I can use?

答案1

得分: 2

你使用了错误的数据库。

我强烈建议您观看YouTube上的各种AWS演示...

特别是这里有一个链接到The Iron Triangle of Purpose - AWS re:Invent 2018: 使用AWS数据库构建:将工作负载与正确的数据库匹配 (DAT301) 演示的PIE定理章节。
如何搜索DynamoDB并提供最佳结果,不受1 MB限制的影响。

DynamoDB提供IE - 无限扩展和效率。

但您需要P - 模式灵活性。

您需要决定是否需要PI或PE。

英文:

You're using the wrong DB.

I'd highly recommend going through the various AWS presentations on YouTube...

In particular here's a link to The Iron Triangle of Purpose - PIE Theorem chapter of the AWS re:Invent 2018: Building with AWS Databases: Match Your Workload to the Right Database (DAT301) presentation.
如何搜索DynamoDB并提供最佳结果,不受1 MB限制的影响。

DynamoDB provides IE - Infinite Scale and Efficiency.

But you need P - Pattern Flexibility.

You'll need to decide if you need PI or PE.

huangapple
  • 本文由 发表于 2023年1月9日 02:11:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75050233.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定