CouchDB中的全文搜索 [英] Full-text search in CouchDB

查看:121
本文介绍了CouchDB中的全文搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,希望得到你的答案: - )



因此,我带了geonames.org并将所有德国城市的数据全部导入如果我输入汉堡,它会列出汉堡中心,汉堡机场等。该应用程序处于封闭的网络中,无法访问互联网,因此我无法访问geonames.org网络服务并需要导入数据。 :(
所有地区的城市都是自动完成的,所以每个关键命中都会导致XHR请求等等。



现在我的客户询问是否有可能拥有全世界的所有数据,最后是大约5.000.000行,包含45.000.000个备选名称等。

Postgres需要大约3秒每一个查询,这使得自动完成不可用。



现在我想到CouchDb,已经使用它了。我的问题:

我想发布Ham,我希望CouchDB获得以Ham开头的所有文档。如果输入Hamburg,我希望它返回Hamburg等等。



CouchDB是它的正确数据库吗?您可以推荐哪些其他数据库以低延迟响应(可能在内存中)以及数百万个数据集?数据集不会定期更改,它相当静态!

解决方案

如果我理解您的问题是正确的,可能您需要的所有内容都已内置CouchDB。


  1. 要获得一系列名称以例如 火腿。您可以在字符串范围内使用请求 startkey =Ham& endkey =Ham \fff0

  2. 如果您需要更全面的搜索,包含其他地方名称作为关键字的视图。所以你可以使用上面的技术再次查询范围。

以下是一个视图函数:

  function(doc){
for(var name in doc.places){
emit(name,doc._id);
}
}

另请参阅CouchOne博客文章 CouchDB键入和自动完成搜索和关于邮件列表的讨论关于 CouchDB自动完成功能


I have a problem and hope to get an answer from you :-)

So, I took geonames.org and imported all their data of German cities with all districts.

If I enter "Hamburg", it lists "Hamburg Center, Hamburg Airport" and so on. The application is in a closed network with no access to the internet, so I can't access the geonames.org web services and have to import the data. :( The city with all of its districts works as an auto complete. So each key hit results in an XHR request and so on.

Now my customer asked whether it is possible to have all data of the world in it. Finally, about 5.000.000 rows with 45.000.000 alternative names etc.

Postgres needs about 3 seconds per query which makes the auto complete unusable.

Now I thought of CouchDb, have already worked with it. My question:

I would like to post "Ham" and I want CouchDB to get all documents starting with "Ham". If I enter "Hamburg" I want it to return Hamburg and so forth.

Is CouchDB the right database for it? Which other DBs can you recommend that respond with low latency (may be in-memory) and millions of datasets? The dataset doesn't change regularly, its rather static!

解决方案

If I understand your problem right, probably all you need is already built in the CouchDB.

  1. To get a range of documents with names beginning with e.g. "Ham". You may use a request with a string range: startkey="Ham"&endkey="Ham\ufff0"
  2. If you need a more comprehensive search, you may create a view containing names of other places as keys. So you again can query ranges using the technique above.

Here is a view function to make this:

function(doc) {
    for (var name in doc.places) {
        emit(name, doc._id);
    }
}

Also see the CouchOne blog post about CouchDB typeahead and autocomplete search and this discussion on the mailing list about CouchDB autocomplete.

这篇关于CouchDB中的全文搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆