在 SQL Server 2008 和 ASP.NET MVC 环境中进行简单站点搜索的策略是什么?

发布于 2024-11-06 05:43:34 字数 897 浏览 0 评论 0原文

我正在尝试制定一种在 ASP.NET MVC 和 SQL Server 2008 中实现非常简单的站点搜索的策略。

实际上,我想做的就是能够根据搜索词的次数对搜索结果进行排名或在网页中找到短语。我尝试使用 LINQtoSQL 来执行此操作,但遇到了很多问题,其中某些 LINQ 命令没有等效的 SQL 命令。这是几个月前的事,所以我不记得具体的错误。

所以,我只是想找出一种方法。我的想法是这样的:

方法1: 我可能应该编写一个程序来抓取网站并以某种方式索引网站的文本 - 我想我应该将信息保存在一个表中,例如:

  • ID
  • Word
  • URL

然后我可以查询它并根据该单词关联的次数进行排名某个网址。但后来我意识到,如果用户搜索一个短语,这种技术就会完全失效。

方法 2: 然后我考虑使用 SPROC 创建一个临时表,其中包含每个 URL 的记录,该表将以某种方式解析文本并确定该短语或单词在每个单独的 URL 中出现的次数。然后我们将从临时表中返回结果。 认为临时表看起来像这样:

  • ID
  • SearchText
  • URLFrequency

然后 select * from temptable order byFrequency asc 或类似的东西。

但是,我不确定 SPROC 是否能够解析这样的文本,或者是否可以同时搜索。

我正在寻找非常轻便的东西。我对使用 Lucene 或 Solr 或类似的东西不太感兴趣,因为学习曲线似乎非常陡峭,而且这些应用程序的功能远远超出了我的需要。

关于我应该如何解决这个问题有什么想法吗?我应该考虑采用不同的方法吗?

I am trying to hash out a strategy for implementing a very simple site search in ASP.NET MVC and SQL Server 2008.

Really, all I want to to do is to be able to rank search results based on the number of times a search word or phrase is found in the webpage. I attempted to do this using LINQtoSQL but I ran into a lot of issues where some LINQ commands don't have a SQL equivalent. This was a few months ago so I don't remember specific errors.

So, I'm just trying to figure out an approach. What I'm thinking is this:

Approach 1:
I should probably write a program to spider the site and somehow index the site's text - I'm thinking I should save information in a table like:

  • ID
  • Word
  • URL

I could then query that and rank based on how many time that word is associated with a certain URL. But then I realized that this technique would completely breakdown if a user was searching for a phrase.

Approach 2:
Then I was toying with the idea of using SPROCs to create a temporary table with a record for each URL that would somehow parse the text and determine how many times the phrase or word appeared in each individual URL. and then we would return the results from the temp table. I am thinking the temporary table would look something like this:

  • ID
  • SearchText
  • URL
  • Frequency

And then select * from temptable order by Frequency asc or something like that.

However, I'm not sure if SPROCs are capable of parsing text like that, or if simultanious searching would be possible.

I am looking for something very lightweight. I'm not really interested in using Lucene or Solr or anything like that because the learning curve seems very steep and those applications' features are far away more than what I need.

Any thoughts on how I should approach this problem? Is there a different approach that I should consider?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

嗫嚅 2024-11-13 05:43:34

对于短语与单词的问题,为什么不使用通配符和 LIKE 运算符呢?

Select Count(*) from temptable where SearchPhrase LIKE  '%Apple%' 

For your phrase versus word issue, why not use wildcards and LIKE operators?

Select Count(*) from temptable where SearchPhrase LIKE  '%Apple%' 
琉璃梦幻 2024-11-13 05:43:34

也许这并不完全是您想要的,但 Windows SharePoint Search Server 并没有那么糟糕。

是的,它里面有“SharePoint”这个词,这通常会让我抓起桌子上的剪刀,开始刺破我的眼睛,但在紧要关头不得不使用它一次,我实际上对它印象深刻。

它是免费的,因此与编写自定义内容相比,也许值得花几个小时来玩它。

Maybe not exactly what you want, but Windows SharePoint Search Server isn't all that bad.

Yes, it has the word 'SharePoint' in it, which would usually make me grab the scissors on my desk and start stabbing my eyes out, but having to use it once in a pinch, I was actually somewhat impressed with it.

It's free, so maybe worth a couple of hours playing with it for comparison to writing something custom.

风蛊 2024-11-13 05:43:34

经过一番研究后,我发现 SQL Server 2008 的全文搜索正是我想要使用的。我还不是 100% 确定,但看起来很有希望。

http://msdn.microsoft.com/en-us/library/ms142547.aspx

After a little poking around, it looks like SQL Server 2008's Full Text Search is what I would want to use. I'm not 100% sure yet, but it looks promising.

http://msdn.microsoft.com/en-us/library/ms142547.aspx

究竟谁懂我的在乎 2024-11-13 05:43:34

如果您正在考虑全文搜索,请查看 lucene.net

我在一个项目中使用了 FTS,后来又在另一个项目中使用了 lucene.net,虽然需求与你的不同,但我现在再也不会回到 FTS 了。

If you're considering Full Text Search, then also check out lucene.net.

I used FTS for one project, and later used lucene.net for another, and although the requirements were different from yours, I'd never go back to FTS now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文