.NET 应用程序 - 搜索问题
我在服务器上有一个 ASP.NET Web 应用程序和一个 List
(在 Application[] 存储中)。产品类有一个名称属性。我需要让用户能够根据名称搜索产品。例如,如果用户键入“本田计算机”,则应用程序必须显示“2001 本田 Passport 发动机计算机 (OEM)”。搜索必须非常快,将来我将添加自动完成功能(AJAX)。
到目前为止,我有几个解决这个问题的想法:
编写或使用 B 树、Trie、后缀树、前缀树等开源实现。不幸的是,数据结构和算法不是我最强的技能(该死的哈佛,这么多钱白花)。
使用搜索引擎 - Lucene.NET、Velocity 或 MemCached.NET。从未使用过,所以我不知道它们是否适用于这种情况。我不需要搜索同义词,而且我的应用程序没有访问文件系统的权限(因此没有索引文件)。
欢迎任何建议。
I've got an ASP.NET web app and a List<Product>
on the server (in the Application[] store). Class Product has a Name property. I need to give users the ability to search for products based on names. For example if the user types 'honda computer', the app has to show '2001 Honda Passport Engine Computer (OEM)'. The search has to be very fast, in future I'll add autocomplete functionality (AJAX).
So far I had a couple ideas how to solve this:
Write or use an open source implementation of something like B-Tree, Trie, Suffix tree, Prefix tree. Unfortunately data structures and algorithms are not my strongest skill (damn Harvard, so much money for nothing).
Use a search engine - Lucene.NET, Velocity or MemCached.NET. Never used one, so I don't know if they will work in this scenario. I don't need to search for synonyms and my app doesn't have permissions to access the file system (so no index file).
Any advice is welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这些产品是否随时存储在数据库中?许多流行的数据库(包括 Microsoft SQL Server)支持自由文本搜索索引,这是跨大型数据集进行文本搜索的快速方法。
Are these products stored in a database at any point? Many popular databases (including Microsoft SQL Server) support free-text search indexing which is a fast way to text search across large datasets.
根据您拥有的数据量,使用后缀树实际上是一个非常好的主意。通常,当文本框启用自动建议时,用户将从短语的开头输入,并且由于您可以根据用户输入的字符来搜索树,因此后缀树将自动过滤掉可能的建议,并通过导航树向您提供要显示的建议。
虽然它们的实现确实很复杂,但您也许能够找到已经为 .NET 编写的一个。但是,由于它们往往非常有用,因此您可以找到一些很好的材料,其中包含有关如何使用的信息编写自己的。
Depending upon how much data you have, using a suffix tree would actually be an extremely good idea. Generally users are going to type from the beginning of a phrase when a text-box has auto-suggest enabled and since you can search the tree on the basis of the characters that are being input by the user input as it, a suffix tree would automatically filter down the possible suggestions and also provide you with the suggestions to display by navigating the tree.
While it is true that they can be complicated to implement, you might be able to find one written for .NET already. However, because they tend to be very useful, you can find some good materials with information on how to write your own.