是否有可能使用 Erlang、Mnesia 和 Web 开发一个强大的网络搜索引擎? 雅司病?
我正在考虑使用 Erlang、Mnesia & 开发一个网络搜索引擎。 雅司病。 是否有可能使用这些软件制作一个功能强大且速度最快的网络搜索引擎? 实现这一目标需要什么以及我该如何开始?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Erlang 可以打造当今最强大的网络爬虫。 让我带您了解我的简单爬虫。
步骤 1. 我创建一个简单的并行模块,我将其称为 mapreduce
步骤 2. HTTP 客户端
人们通常会使用 erlang 内置的
inets httpc module
或ibrowse
。 然而,为了内存管理和速度(使内存占用尽可能低),优秀的 erlang 程序员会选择使用卷曲
。 通过应用os:cmd/1 采用curl 命令行,可以将输出直接输入到erlang 调用函数中。 然而,最好让curl将其输出扔到文件中,然后我们的应用程序有另一个线程(进程)来读取和解析这些文件
So you can spawn many processes. You remember to escape the URL as well as the output file path as you execute that command. There is a process on the other hand whose work is to watch the directory of downloaded pages. These pages it reads and parses them, it may then delete after parsing or save in a different location or even better, archive them using the
zip module
步骤 3.html 解析器。
更好地使用这个
mochiweb 的 html解析器和 XPATH
。 这将帮助您解析并获取所有您喜欢的 HTML 标签,提取内容,然后就可以开始了。 在下面的示例中,我仅关注标记中的Keywords
、description
和title
在 shell 中进行模块测试...非常棒的结果!!!
您现在可以意识到,我们可以根据关键字对页面进行索引,并制定良好的页面重新访问计划。 另一个挑战是如何制作一个爬虫(可以在整个网络中从一个域移动到另一个域的东西),但这很容易。 可以通过解析 Html 文件中的 href 标签来实现。 让 HTML 解析器提取所有 href 标签,然后您可能需要一些正则表达式来获取给定域下的链接。
运行爬虫
Storage: Is one of the most important concepts for a search engine. Its a big mistake to store search engine data in an RDBMS like MySQL, Oracle, MS SQL e.t.c. Such systems are completely complex and the applications that interface with them employ heuristic algorithms. This brings us to Key-Value Stores, of which the two of my best are
Couch Base Server
andRiak
. These are great Cloud File Systems. Another important parameter is caching. Caching is attained using sayMemcached
, of which the other two storage systems mentioned above have support for it. Storage systems for Search engines ought to beschemaless DBMS
,which focuses onAvailability rather than Consistency
. Read more on Search Engines from here: http://en.wikipedia.org/wiki/Web_search_engineErlang can make the most powerful web crawler today. Let me take you through my simple crawler.
Step 1. I create a simple parallelism module, which i call mapreduce
Step 2. The HTTP Client
One would normally use either
inets httpc module
built into erlang oribrowse
. However, for memory management and speed (getting the memory foot print as low as possible), a good erlang programmer would choose to usecurl
. By applying theos:cmd/1
which takes that curl command line, one would get the output direct into the erlang calling function. Yet still, its better, to make curl throw its outputs into files and then our application has another thread (process) which reads and parses these filesSo you can spawn many processes. You remember to escape the URL as well as the output file path as you execute that command. There is a process on the other hand whose work is to watch the directory of downloaded pages. These pages it reads and parses them, it may then delete after parsing or save in a different location or even better, archive them using the
zip module
Step 3. The html parser.
Better use this
mochiweb's html parser and XPATH
. This will help you parse and get all your favorite HTML tags, extract the contents and then good to go. The examples below, i focused on only theKeywords
,description
andtitle
in the markupModule Testing in shell...awesome results!!!
You can now realise that, we can index the pages against their keywords, plus a good schedule of page revisists. Another challenge was how to make a crawler (something that will move around the entire web, from domain to domain), but that one is easy. Its possible by parsing an Html file for the href tags. Make the HTML Parser to extract all href tags and then you might need some regular expressions here and there to get the links right under a given domain.
Running the crawler
Storage: Is one of the most important concepts for a search engine. Its a big mistake to store search engine data in an RDBMS like MySQL, Oracle, MS SQL e.t.c. Such systems are completely complex and the applications that interface with them employ heuristic algorithms. This brings us to Key-Value Stores, of which the two of my best are
Couch Base Server
andRiak
. These are great Cloud File Systems. Another important parameter is caching. Caching is attained using sayMemcached
, of which the other two storage systems mentioned above have support for it. Storage systems for Search engines ought to beschemaless DBMS
,which focuses onAvailability rather than Consistency
. Read more on Search Engines from here: http://en.wikipedia.org/wiki/Web_search_engine据我所知Powerset的自然语言处理搜索引擎是使用erlang开发的。
您是否将 couchdb (也是用 erlang 编写的)视为可以帮助您的工具解决路上的一些问题?
As far as I know Powerset's natural language procesing search engine is developed using erlang.
Did you look at couchdb (which is written in erlang as well) as a possible tool to help you to solve few problems on your way?
我会推荐 CouchDB 而不是 Mnesia。
YAWS 相当不错。 您还应该考虑 MochiWeb。
使用 Erlang 不会出错
I would recommend CouchDB instead of Mnesia.
YAWS is pretty good. You should also consider MochiWeb.
You won't go wrong with Erlang
在'rdbms'贡献中,有波特词干算法的实现。 它从未集成到“rdbms”中,所以它基本上只是坐在那里。 我们已经在内部使用了它,并且它运行得很好,至少对于不太大的数据集来说(我还没有在巨大的数据量上测试过它)。
相关模块有:
当然还有Disco Map-Reduce 框架。
我不能说你是否能制造出最快的引擎。 是否存在更快搜索引擎的市场? 我从来没有遇到过谷歌等速度的问题。 但是,如果有一个搜索工具能够增加我找到问题良好答案的机会,我就会感兴趣。
In the 'rdbms' contrib, there is an implementation of the Porter Stemming Algorithm. It was never integrated into 'rdbms', so it's basically just sitting out there. We have used it internally, and it worked quite well, at least for datasets that weren't huge (I haven't tested it on huge data volumes).
The relevant modules are:
Then there is, of course, the Disco Map-Reduce framework.
Whether or not you can make the fastest engine out there, I couldn't say. Is there a market for a faster search engine? I've never had problems with the speed of e.g. Google. But a search facility that increased my chances of finding good answers to my questions would interest me.