英文:
How to search through dynamodb and provide best result irrespective of 1 mb limit
问题
我一直在一个使用DynamoDB存储帖子列表的项目上工作。
以下是我的目标:
- 能够发布和更新帖子(已完成)
- 用户能够搜索帖子列表(已完成)
问题出在扫描操作的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提供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 provides IE - Infinite Scale and Efficiency.
But you need P - Pattern Flexibility.
You'll need to decide if you need PI or PE.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论