.NET Application - search problem
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 implement开发者_开发技巧ation 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.
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.
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.
精彩评论