如何使用MongoDB实现关键字和位置搜索?
我正在尝试实现一个网络/智能手机应用程序,允许用户根据关键字和位置搜索地点,要求如下:
- 用户应能够通过输入关键字和位置进行搜索;位置可以是邮政编码、城市/州或移动应用程序中的当前位置(纬度和经度)
- 我们希望能够自定义相关性分数;我们需要能够基于关键词匹配、位置匹配和其他一些参数来定义我们自己的相关性算法。
我们使用 ASP.NET MVC 作为 Web 开发框架,使用 MongoDB 作为数据存储。我们还在数据库中维护所有邮政编码和城市/州及其质心(纬度/经度)的列表。我们的想法是用我们自己的算法覆盖全文系统提供的评分(如 Lucene 评分)。我正在努力寻找解决此问题的最佳解决方案。我想知道我们是否应该使用 MongoDB 全文搜索,或者尝试使用 Lucene .NET 或者 Solr?任何帮助/指示/评论总是值得赞赏!
I am trying to implement a web/smart phone app that allow users to search for places based on keywords and location and here is the requirement:
- Users shall be able to search by typing in keywords and location; Locations can be zip code, city/state or current location from the mobile app (lat and long)
- We would like to be able to customize relevance score; We need to be able to define our own relevance algorithm based on keyword matching, location matching and some other parameters.
We use ASP.NET MVC as our web development framework and MongoDB as a data store. We also maintain a list of all zipcode and city/state as well as their centroid (lat/long) in our database. Our thought is override the scoring that the full-text system provide (like Lucene scoring) with our own algorithm. I am trying to find the best solution to address this. I am wondering whether should we use MongoDB full-text search or try to use Lucene .NET or perhaps Solr? Any help/pointer/comment is always apprecated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,首先,MongoDB 不支持全文搜索。
它具有一些正则表达式功能,您可以在数组上建立索引。因此,您可以在这里做一些事情,例如构建关键字数组以使基本文本搜索成为可能。
然而,这与Solr和Sphinx相比还有很长的路要走。
您将遇到的另一个大问题是相关性评分。使用 MongoDB 执行任何类型的服务器端相关性评分都将非常困难。服务器端存储过程没有真正有效的版本。您可能必须将结果提取到专用于该评分的客户端或服务器。
So as a starting point, MongoDB does not have support for full-text search.
It has some regex capabilities and you can index on arrays. So you can do some things here, like building an array of keywords to make basic text search possible.
However, this is a long way from what Solr and Sphinx.
The other big problem you'll have is with relevance scoring. It's going to be very difficult to perform any type of server-side relevance scoring with MongoDB. There's no really efficient version of a server-side stored procedure. You'll likely have to pull the results to a client or server dedicated to that scoring.