针对 NoSQL 键值对执行上下文搜索的正确方法是什么?
使用 MySQL,我可能会搜索表“photos”来查找匹配的标题,如下所示:
SELECT *
FROM photos
WHERE title LIKE '[string]%';
如果字段“title”已建立索引,则执行效率会相当高。我什至可以在标题字段上设置全文索引来执行子字符串匹配。
对 NoSQL 照片表(例如 Amazon 的 DynamoDB)执行类似搜索的好策略是什么,格式为:
{key} ->照片_id, {值} -> {照片 ID = 2332532532235, title = 'this is a title'}
我想一种方法是搜索每个条目值的内容并返回匹配项。但这似乎效率很低,尤其是当数据集变得非常大时。
提前致谢。
With MySQL, I might search through a table "photos" looking for matching titles as follows:
SELECT *
FROM photos
WHERE title LIKE '[string]%';
If the field "title" is indexed, this would perform rather efficiently. I might even set a FULLTEXT index on the title field to perform substring matching.
What is a good strategy for performing a similar search against a NoSQL table of photos, like Amazon's DynamoDB, in the format:
{key} -> photo_id,
{value} -> {photo_id = 2332532532235,
title = 'this is a title'}
I suppose one way would be to search the contents of each entry's value and return matches. But this seems pretty inefficient, especially when the data set gets very large.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以给你一个 Mongo shell 的例子。
来自 MongoDB 站点上的基本教程:
现在您有一个名为 things 的集合,并在其中存储了两个文档。
假设您现在想要执行与
SQL 中相同的操作,这将返回“mongo”记录。
在 Mongo Shell 中,您可以执行以下操作:
这将返回“mongo”文档。
希望这有帮助。
阿蒂什
I can give you a Mongo shell example.
From the basic tutorial on MongoDB site:
So you now have a collection called things and have stored two documents in it.
Suppose you now want to do the equivalent of
In SQL, this would have returned you the "mongo" record.
In Mongo Shell, you can do this:
This returns the "mongo" document.
Hope this helps.
Atish