使用 ASP.NET MVC 访问 Windows 搜索索引

发布于 2024-09-09 04:35:55 字数 962 浏览 1 评论 0原文

我正在进行的项目正在从 vbscript 升级到 ASP.NET MVC。它使用 Microsoft Index Server 在 Windows Server 2003 计算机上索引 Word 和 PDF 文件。它只是使用“Provider=\”MSIDXS\”;Data Source=\“docSearch\”;”之类的连接字符串打开 OleDbConnection。

经过一番研究后,我了解到索引服务器已过时(“注意索引服务从 Windows XP 开始已过时。相反,请使用 Windows 搜索。” - http://msdn.microsoft.com/en-us/library/ms690580),Windows Search 是后继者。
因此,在我的新 MVC 应用程序中,我尝试使用 OleDbConnection 与连接字符串(如“Provider=Search.Collat​​orDSO;Extended Properties=\”Application=Windows\””)进行连接。

我有一个接受格式化查询并执行搜索的方法 - 这是使用 OleDb 执行的查询:

string.Format("SELECT System.FileName FROM SystemIndex WHERE CONTAINS('{0}')", query)

现在,当我在测试类中调用我的方法时,它工作正常(即返回结果... myDataReader.HasRows是真的)。但是,当我从 MVC 控制器调用相同的方法时,它使用相同的查询不返回任何结果 - myDataReader.HasRows 为 false。我的猜测是与权限有关,并且 IIS 无法访问索引。如何让 IIS 能够访问索引?如何将索引公开给 ASP.NET 网页?如果索引服务器已过时,并且 Windows 搜索不支持此功能,我应该使用什么?

I'm on a project that is being upgraded from vbscript to ASP.NET MVC. It used Microsoft Index Server to index Word and PDF files on a Windows Server 2003 machine. It simply opened an OleDbConnection using a connection string like "Provider=\"MSIDXS\";Data Source=\"docSearch\";".

After researching a bit, I learned that Index Server is obsolete ("Note Indexing Service is obsolete as of Windows XP. Instead, use Windows Search." - http://msdn.microsoft.com/en-us/library/ms690580) and Windows Search is the successor.
So, in my new MVC app, I'm trying to connect using OleDbConnection with a connection string like "Provider=Search.CollatorDSO;Extended Properties=\"Application=Windows\"".

I have a method that takes in a formatted query and executes the search - here is the query that gets executed using OleDb:

string.Format("SELECT System.FileName FROM SystemIndex WHERE CONTAINS('{0}')", query)

Now, when I call my method in a test class, it works fine (i.e. returns results... myDataReader.HasRows is true). But, when I call the same method from my MVC Controller, it returns no results - myDataReader.HasRows is false - using the same query. My guess is something to do with permissions and IIS not being able to access the index. How can I get IIS to have access to the index? How can I expose the index to a ASP.NET web page? If Index Server is obsolete, and this functionality isn't supported in Windows Search, what am I supposed to use?

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

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

发布评论

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

评论(2

香草可樂 2024-09-16 04:35:55

我不会仅仅因为它不受支持而进行更改,除非您在索引服务方面遇到特定问题或需要新版本的功能。

我将从 ISearchQueryHelper 获取连接字符串

该服务是否具有正确的权限?您检查过Windows Search 3.0/4.0 SDK吗?

我看到您在论坛上 (http://social.msdn.microsoft.com/Forums/en-US/windowsdesktopsearchdevelopment/thread/7b9eead4-d938-42c6-ba2b-2c238a7706f9

我不确定Windows搜索 确实可以取代网站的索引服务。例如,只有一个名为“SystemIndex”的索引,它包含本地系统上的所有内容。因此,如何将结果限制为仅一个网站?

我相信你需要使用“企业搜索”或“搜索服务器”,我对此没有经验。

由于索引服务Windows 搜索的结果都是ADO.NET,因此显示方式没有太大变化。 API 的差异很大,您需要进行许多更改。例如,Windows Search 中没有“范围”。当我更改个人“桌面搜索”应用程序时,需要一个小时才能完成更改,但由于 API 更改,需要两天时间才能复制索引服务所拥有的所有功能。我进行此更改是因为在“代码库”中搜索代码片段时,Windows 搜索 效果更好。

对于没有正则表达式、通配符或非标准属性的标准查询,两者执行相同。 索引服务总是能够更快地检索数据,但可能不会执行一些“成本太高”的查询。 Windows Search 可能需要很长时间才能检索数据,具体取决于查询。通常,这些“长查询”是索引服务“成本太高”的查询。 “长查询”也可能是由检索索引中未包含的属性的任何查询产生的。

我仍然在 Windows Server 2003 上为我的网站使用索引服务,并且不打算进行任何更改,因为它并不像我预期的那么容易,而且没有令人信服的东西这样做的理由。

I would not change just because it is not supported unless you are having a specific problem with Indexing Service or need a feature from the newer version.

I would get connection string from ISearchQueryHelper

Does the service have the correct permissions? Have you checked the Windows Search 3.0/4.0 SDK?

I see you are on the forum (http://social.msdn.microsoft.com/Forums/en-US/windowsdesktopsearchdevelopment/thread/7b9eead4-d938-42c6-ba2b-2c238a7706f9)

I am not sure Windows Search can really replace Indexing Service for Web sites. For instance, there is only one index called "SystemIndex" which contains everything on the local system. Therefore, how would you limit the results to just a Web site?

I believe you need to use "enterprise search" or "search server", which I have no experience with.

Since the results for both Indexing Service and Windows Search are ADO.NET, the presentation does not change much. The API is different enough that you will need to make many changes. For instance, there is no "scope" in Windows Search. When I changed over my personal "desktop search" application, it took an hour to make the change, but two days to duplicate all the functionality that I had with Indexing Service because of the API changes. I made this change because Windows Search is better when searching for code snippets in my "Code Library"

For standard queries with no regular-expressions or wild-cards or non-standard properties, both perform the same. Indexing Service always retrieves data quicker, but may not perform some queries that are "too expensive". Windows Search can take a long time retrieving the data depending on the query. Typically, these "long queries" are the "too expensive" queries of Indexing Service. "Long queries" can also result from any query that retrieves a property that is not contained in the index.

I am still using Indexing Service for my web sites on Windows Server 2003 and do not plan to make any changes because it is not as easy as I expected and there is no compelling reason to do.

天荒地未老 2024-09-16 04:35:55

我在这里找到了答案 ASP.NET OLEDB 代码在部署时中断IIS7。通过模拟有权访问索引的用户。

I found my answer here ASP.NET OLEDB code breaks when deployed on IIS7. By impersonating a user that has access to the index.

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