IIS 5.0IIS 5.1IIS 6.0Visual Studio .NET 2002SQL Server 2000.NET 1.0DBAIISVisual Studio .NET 2003Windows 2003.NET 1.1Windows 2000IntermediateDevVisual StudioSQL ServerSQLWindows.NETVisual BasicASP.NETC#
Microsoft Content Management Server 搜索控件






4.36/5 (5投票s)
为内容管理服务器网站提供搜索功能,使用 SharePoint Portal Server 作为搜索引擎。
引言
这一套用户控件为 Microsoft 内容管理服务器 (MCMS) 网站提供了搜索功能,使用 SharePoint Portal Server (SPS) 作为搜索引擎。它利用 SPS 的搜索 Web 服务提供简单的关键字搜索。提供了一个搜索选项来选择特定的内容索引。搜索结果显示在一个可自定义的 DataGrid
中。
此用户控件集的 C# 版本可在此 处 下载。
SharePoint 设置
请参考 Emmanuel Desigaud 关于如何设置 SPS 进行搜索的 文章。基本而言,您需要设置一个内容索引并添加一个内容源。另外,请确保在您的 CMS 网站中执行搜索的用户有权访问 SPS 搜索 Web 服务。
安装
- 将 SPSSearch.xml 复制到您的 XML 目录(如果您有的话),或网站中的任何位置。如果您希望在搜索结果中包含其他列,请将这些字段添加到 select 语句中。您还可以更改
<Count>500</Count>
中返回的最大搜索结果数量,如果需要的话。 - 将用户控件
SearchInput
复制到您的用户控件目录。默认搜索按钮是一个文本按钮。如果您想要一个图像按钮,请相应地更改SearchButton
和SearchImageButton
的Visible
属性,并更新SearchImageButton
的ImageUrl
。即使您不使用其中一个按钮,也不要删除它们。 - 将用户控件
SearchResults
复制到您的用户控件目录。如果您在 SPSSearch.xml 中添加了其他字段,请自定义 SearchResult.ascx 以包含这些字段。 - 您可能需要在 SearchInput.ascx、SearchInput.ascx.vb、SearchResults.ascx 和 SearchResults.ascx.vb 中使用项目名称限定某些命名空间。
- 将 QueryService.vb 和 SearchUtilities.vb 复制到您的类目录。
- 将 Search.css 复制到您的 CSS 目录。
- 在您的 web.config 中,将以下键添加到
appSettings
<appSettings> <add key="QuestechSystems.SPSSearchUrl" value="http://<SPSServer>/_vti_bin/search.asmx" /> <add key="QuestechSystems.SPSSearchXml" value="[Url to SPSSearch.xml]" /> <add key="QuestechSystems.SPSSearchIndexesText" value="[A comma delimited list of Content Indexes Display Name]" /> <add key="QuestechSystems.SPSSearchIndexesValue" value="[A comma delimited list of Content Indexes]" /> </appSettings>
例如
<appSettings> <add key="QuestechSystems.SPSSearchUrl" value="http://<SPSServer>/_vti_bin/search.asmx" /> <add key="QuestechSystems.SPSSearchXml" value="/<CMS Site Application Name>/Xml/SPSSearch.xml" /> <add key="QuestechSystems.SPSSearchIndexesText" value="All,Sub Site 1,Sub Site 2" /> <add key="QuestechSystems.SPSSearchIndexesValue" value="All,Sub_Site_1_Content_Index,Sub_Site_2_Content_Index" /> </appSettings>
将在
SearchInput
用户控件中添加一个下拉列表用于内容索引。SPSSearchIndexesValue
中的“All
”是一个特殊值,它定义了在SPSSearchIndexesValue
中定义的所有内容索引上执行搜索。如果您只有一个内容索引要搜索,则添加以下内容代替<appSettings> <add key="QuestechSystems.SPSSearchUrl" value="http://<SPSServer>/_vti_bin/search.asmx" /> <add key="QuestechSystems.SPSSearchXml" value="/<CMS Site Application Name>/Xml/SPSSearch.xml" /> <add key="QuestechSystems.SPSSearchIndexesValue" value="Site_Content_Index" /> </appSettings>
在这种情况下,将不添加下拉列表。
- 将用户控件
SearchInput
添加到您的 CMS 网站中您希望显示搜索输入框的位置。结果页面的 URL 通过SearchResultsUrl
属性指定。搜索结果页面可以是 CMS 模板页面或普通的 ASP.NET 页面。例如<%@ Register TagPrefix="uc1" TagName="SearchInput" Src="~/UserControls/SearchInput.ascx" %> . . . . . . <uc1:SearchInput id="SearchInput" SearchResultsUrl="" DefaultSearchIndex="" runat="server"> </uc1:SearchInput>
如果未指定
SearchResultsUrl
,则当前页面将用作结果页面。如果您指定了多个内容索引,则可以使用DefaultSearchIndex
属性选择要搜索的默认内容索引。自定义 SearchInput.ascx 以更改搜索输入元素的布局。 - 将用户控件
SearchResult
添加到您的搜索结果页面。该控件有两个属性可以设置DefaultPageSize
:每页搜索结果的数量。默认为 10。FilterRights
:[True
|False
]。默认情况下,搜索结果将过滤掉您无权查看的任何 CMS 页面。如果您的搜索结果不包含任何授权内容和/或您想提高性能,请将其设置为False
。但请谨慎使用。
- 将 Search.css 包含到所有引用搜索控件的页面中。
- 将所有新文件包含到您的 CMS 项目中。在 VS.NET 中重新构建您的网站。
注释
- 如果 SearchResults 遇到任何错误,它将掩盖错误并返回“未找到页面”。要查看实际错误,请向搜索结果页面添加查询字符串“debug=true”并重新加载页面。
- 搜索控件在 CMS 未发布模式下运行。然而,搜索结果中返回的链接都是已发布的链接。
历史
- V1.0 - 2004.07.26 - 基础版本。
- V1.1 - 2004.08.20 - 启用对元关键字和描述的搜索。
- V1.2 - 2005.02.05 - 添加了搜索多个内容索引的选项。
- V1.3 - 2005.02.13 - 在 web.config 中添加了可配置的 SPS 搜索 Web 服务 URL,以方便部署。(请注意:所有 Web.Config 的 App Settings 键名现在都已添加命名空间限定。)
- V1.4 - 2005.06.25 - 支持精确短语搜索。