使用ASP.NET MVC,SQL Server,实体框架实现搜索框 [英] Implementing a Search Box using ASP.NET MVC, SQL Server, Entity Framework

查看:117
本文介绍了使用ASP.NET MVC,SQL Server,实体框架实现搜索框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有建立搜索解决方案的经验,但我想在我的解决方案中有一个搜索框,我不知道甚至开始。有没有很酷的SQL Server技巧,我可以用来使我的搜索解决方案执行(我正在使用托管SQL 2008服务器)我希望指向一个多步骤教程,启动我一个简单的查询搜索解决方案。 。然后在更高级的代码和功能上进行分层。

I have no experience building a search solution, but I'd like to have a search box within my solution and I don't know where to even begin. Are there cool SQL Server tricks that I can use to make my search solution performant (I'm using a hosted SQL 2008 server) I'd love pointers to a multi-step tutorial that starts me off with a simple query search solution...and then layers on more advanced code and features.

推荐答案

你实际上并不说是否需要/想要一个蜘蛛像您一样索引您的网站(如Google;如果每个页面上的可搜索内容来自许多不同的表/对象/实体),或者您是否只想使用全文本搜索语法查询EF,这很有用返回一个实体集合?

You don't actually say whether you need/want a 'spider' to index your site "as is" (like Google; which is useful if your searchable content on each page comes from many different tables/objects/entities) or whether you just want to query EF using full-text-search-like syntax to return a collection of Entities?

如果您对蜘蛛方法感兴趣,这里是一个适用于小型ASP.NET搜索引擎的CodeProject文章 Searcharoo 。它是一个针对小型网站的网络爬行搜索引擎(根本不使用数据库),因此可能不适用于您的情况。
代码也在 searcharoo.codeplex.com ,有7条关于它的工作原理/是建立在 Searcharoo.net (免责声明:我写了他们;我希望他们有趣/有用)。

If you are interesting in the 'spider' approach - here's a CodeProject article for a small ASP.NET Search Engine "Searcharoo". It is a web-crawling search engine for small-ish sites (it doesn't use a database at all), so it may not be applicable for your situation. The code is also at searcharoo.codeplex.com and there are 7 articles on how it works/was built at Searcharoo.net (disclaimer: I wrote them; I hope they are interesting/useful).

如果您需要直接搜索数据库,您应该可以查看SQL Server 2008的全文搜索功能(假设 LIKE isn对您的需求不够完善)。我们使用了这篇文章(免费注册)的信息在工作项目中设置SQL全文搜索...在我们的解决方案中没有EF。

If you need to search your database directly, you should probably look into SQL Server 2008's Full Text Search feature (assuming LIKE isn't sophisticated enough for your needs). We used info from this article (free registration) to set-up SQL Full Text Search on a work project... no EF in our solution though.

另外,你可能知道StackOverflow是用ASP.NET构建的MVC - 他们发表了关于一些 SQL 2008 FTS问题的博客。还有关于SQL FTS的某些信息 Lucene.NET(这是您可以研究的另一个搜索引擎),可能是有用的。

Also, as you might know StackOverflow is built with ASP.NET MVC - they blogged about some problems with SQL 2008 FTS. There's also some info on SQL FTS versus Lucene.NET (which is another search engine you could research) that might be useful.

这篇关于使用ASP.NET MVC,SQL Server,实体框架实现搜索框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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