在 SharePoint Server 中配置搜索结果 Web 部件的属性

适用于:yes-img-132013 yes-img-162016 yes-img-192019 yes-img-seSubscription Edition no-img-sopSharePoint in Microsoft 365

搜索结果 Web 部件显示在搜索框 Web 部件中输入的查询的搜索结果。 默认情况下,搜索结果 Web 部件用于所有垂直搜索页(results.aspx、peopleresults.aspx、conversationresults.aspx、videoresults.aspx)上。 搜索结果 Web 部件显示实际搜索结果,并且将搜索结果传递给相同页面上的精简 Web 部件和搜索导航 Web 部件。

搜索结果 Web 部件使用 Web 部件中指定的查询来显示搜索结果。 默认情况下,该 Web 部件中定义的查询使用查询变量 {searchboxquery}。 查询变量是值的占位符。 运行查询时,占位符被替换为一个值。 例如,当用户在搜索框 Web 部件中键入搜索短语 yellow 时,搜索结果 Web 部件中的 {searchboxquery} 变量将解析为搜索包含短语 yellow 的所有项。

通过更改搜索结果 Web 部件中的属性和查询,可以执行以下操作:

  • 将搜索结果限制到一个结果源。

  • 添加为不同用户自定义搜索结果的查询变量或属性筛选器。

  • 升级或降级搜索结果中的项或页面。

  • 更改搜索结果的排序。

  • 更改显示模板。

开始之前

注意

[!注意] 因为 SharePoint Server 在 Internet Information Services (IIS) 中作为网站运行,所以管理员和用户依赖于浏览器提供的辅助功能。 SharePoint Server 支持受支持的浏览器的辅助功能。 有关详细信息,请参阅以下资源:

配置搜索结果 Web 部件的属性

配置搜索结果 Web 部件的属性

  1. 确认执行此过程的用户帐户是企业搜索中心网站上 SharePoint 组“Designers”的成员。

  2. 在搜索结果页上,单击"设置"菜单,然后单击"编辑页面"。

  3. 在搜索结果 Web 部件中,单击"搜索结果 Web 部件菜单"箭头,然后单击"编辑 Web 部件"。

  4. 在 Web 部件工具窗格中的"搜索条件"部分,单击"更改查询"。

  5. 在“基本”选项卡上,执行以下操作之一:

  • 若要使用关键字查询语言 (KQL) 定义查询,请选择下面列出的选项:

    • 选择查询

      选择结果源以指定应搜索的内容。

      默认情况下,为不同垂直搜索页设置以下结果源:

      • 全部 (results.aspx):"本地 SharePoint 结果(系统)"

      • 人员 (peopleresults.aspx):"本地人员结果(系统)"

      • 对话 (conversationresults.aspx):"对话(系统)"

      • 视频 (videoresults.aspx):"本地视频结果(系统)"

    • 关键字筛选器

      您可以使用关键字筛选器将查询变量添加到您的查询中。 有关可用查询变量的列表,请参阅Query variables in SharePoint Server

      You can select pre-defined query variables from the drop-down list, and then add them to the query by clicking Add keyword filter.

    • 属性筛选器

      您可以使用属性筛选器查询搜索架构中设置为可查询的 托管属性的内容。

      您可以从“属性筛选器”下拉列表中选择托管属性。 Click Add property filter to add the filter to the query.

    • 查询文本

      默认情况下,查询变量 {searchboxquery} 是针对此字段定义。 可以通过使用 KQL 更改查询文本。 有关 KQL 的详细信息,请参阅关键字查询语言 (KQL) 语法参考。 或者,可以使用" 关键字筛选器"和" 属性筛选器"列表生成查询。

      关键字查询由自由文本关键字、属性筛选器或运算符组成。 查询变量用大括号括起。 运行查询时,查询变量将被实际值替换。

      关键字查询的最大长度为 2048 个字符。

  • To define your query by using pre-defined variables, click Switch to Quick Mode. Select options as described in the following list:

    • 选择查询

      选择结果源以指定应搜索的内容。 如果您已将文档库或列表共享为目录,目录结果源将显示在此下拉列表中。

    • 按应用程序限制

      从列表中选择一个选项以将结果限制为特定的网站、库、列表或 URL。

    • 通过标记限制

      您可以将结果限制为用术语集中的术语标记的内容。

      选择下列选项之一:

      • 不通过任何标记限制

        不按标记限制搜索结果(默认)。

      • 通过当前页面的导航术语限制

        搜索结果将限制为用当前页的术语标记的内容。 当前标记显示为友好 URL 的最后部分。 此选项只对使用托管导航的网站有意义。

      • 按当前导航和子导航限制

        搜索结果将限制为用当前页术语标记的内容(显示为友好 URL 的最后部分),以及用当前页的子术语标记的内容。 此选项只对使用托管导航的网站有意义。

      • 使用此标记限制

        搜索结果将限制为用您在框内键入的标记所标记的内容。

    Note: When you switch to from Quick Mode to Advanced Mode, the result source that you selected from Select a query is replaced by a different result source. This result source could affect the search results. Therefore, make sure that you check the search results that are displayed in the SEARCH RESULT PREVIEW section, and add query configuration in the Query text field if you need to.

  1. The REFINERS tab lists the managed properties that are enabled as refiners in the search schema. You can specify that the search results returned in the Search Results Web Part should be limited to one or more values from the refiners. Select a refiner in the list, and then click Add to add it to the query.

    Click Show more if you want to define grouping of results. 在"对结果进行分组"下,您可以指定结果应基于一个或多个托管属性进行分组。 当您显示给定项目的多个变体并且要根据单个结果进行分组时,这很有帮助。

  2. 在"排序"选项卡上,您可以指定搜索结果的排序方式。 此选项卡仅在使用"高级模式"时才有效。 If you use Quick Mode, you can define sorting options in the result source.

    在"排序依据"下拉列表中:

  3. Select a managed property from the list of managed properties that are set as sortable in the search schema, and then select Descending or Ascending. To add more sorting levels, click Add sort level.

    注意

    搜索结果排序需区分大小写。

    重要

    如果结果源包含排序,则不应在搜索结果 Web 部件中指定排序。 这是因为结果源中的排序将替代在搜索结果 Web 部件中指定的排序。

  4. Select Rank to sort by relevance rank. You can then specify which ranking model to use or specify dynamic ordering rules.

    • (可选)选择用于"排名模型"列表排序的排名模型。

    • Under Dynamic ordering, you can specify additional ranking by adding rules that will change the order of results when certain conditions apply. Click Add dynamic ordering rule, and then specify conditional rules.

  5. 在“设置”选项卡上,指定下面列出的设置。

  • 查询规则

    选择是否使用查询规则。

  • "URL 重写"

    Select if the URL rewrite to the item details page should continue to be relative for each catalog item as defined when you set up the catalog connection. This option is only meaningful for sites that use managed navigation and have connected to a catalog that uses anonymous access for the catalog pages. If you select Don't rewrite URLs, the URLs for catalog items are pointed directly to the library item of the connected catalog.

  • 加载行为

    Select when the search results returned by the Search Results Web Part appear on the web page. The default option is Async option: Issue query from the browser. Queries will be issued from the end-users browser after the complete page is received (asynchronous). If you select the synchronous option, Sync option: Issue query from the server, queries are issued from the server, and the search results are included in the page response that is sent back from SharePoint (synchronous). 同步加载使搜索容易受到跨站点请求伪造攻击,只有在仔细考虑是否可以利用此漏洞后 ,才 应选择此选项,了解详细信息。

  1. 在“测试”选项卡上,可以预览搜索结果 Web 部件发送的查询。
  • 查询文本

    显示搜索结果 Web 部件将运行的最后查询。 它基于用当前值替换动态变量的原始查询模板。 对查询的其他更改可能需要作为查询规则的一部分。

单击“显示更多”,以显示其他信息。

  • 查询模板

    显示应用于查询的查询模板的内容。

  • 精简依据

    显示"精简程序"选项卡上定义的应用于查询的精简程序。

  • 分组依据

    显示在"精简程序"选项卡上定义的应作为搜索结果分组依据的托管属性。

  • 应用的查询规则

    显示应用于查询的查询规则。

The Query template variables section shows the query variables that will be applied to the query, and the values of the variables that apply to the current page. You can type other values to test the effect they will have on the query. Click the Test Query button to preview the search results.

You can also test how the query works for different user segment terms. Click Add user segment term to add terms to be added to the query.

单击“测试查询”按钮,以预览搜索结果。

  • 查询文本

    显示搜索结果 Web 部件将运行的最后查询。 它基于用当前值替换动态变量的原始查询模板。 对查询的其他更改可能需要作为查询规则的一部分。

  1. In the Web Part tool pane, in the Display Templates section, the default selection is Use result types to display items. This selection will apply different display templates according to the result type of the search result. For example, if the result type of a search result is a PDF file, the display template PDF Item will be applied. If the result type of a search result is an image, the Picture Item display template will be applied. To apply one display template to all result types of the search results, select Use a single template to display items, and then select the display template that you want to apply.

  2. 在 Web 部件工具窗格的"设置"部分的"结果设置"中,要进一步指定搜索结果的显示方式,请更改以下字段中的值:

  • 每页的结果数每页将显示的搜索结果数。

  • 显示排名结果如果您希望只显示已升级的块(例如,已升级的结果或个人收藏夹)或结果控件(例如,结果计数),而不显示排名结果,则清除该复选框。

  • 显示已升级的结果如果您不想显示已通过使用查询规则升级的搜索结果,则清除该复选框。

  • 显示“你的意思是吗? 如果不想显示查询拼写更正,请清除复选框,因为 是否意味着 建议。 有关查询拼写更正的详细信息,请参阅 在 SharePoint Server 中管理查询拼写更正

  • 显示个人收藏夹:如果不想显示个人收藏夹,则清除该复选框。

  • 显示"查看重复项"链接如果您想要显示" 查看重复项"链接,则选中该复选框。

  • 显示至搜索中心的链接如果您想要显示至搜索中心的链接,则选中该复选框。

  1. 在 Web 部件工具窗格中"设置"部分的"结果控制设置"部分中,要指定搜索结果的显示方式,请更改以下字段中的值:
  • 显示高级链接如果您不想在 Web 部件中显示指向高级搜索页的链接,则清除该复选框。

  • 显示结果计数如果您不想在 Web 部件中显示找到的结果数,则清除该复选框。

  • 显示语言下拉列表如果您不想在 Web 部件中显示语言下拉列表,则清除该复选框。

  • 显示排序下拉列表如果您想要在 Web 部件中显示排序下拉列表,则选中该复选框。

  • 显示分页如果您不想在 Web 部件中显示分页,则清除该复选框。

  • 显示首选项链接:如果不想在 Web 部件中显示指向首选项页的链接,则清除该复选框。

  • Show AlertMe link Clear the check box if you don't want to show a link to the Alert Me page in the Web Part. For more information about search alerts, see Enable search alerts in SharePoint Server.

禁用搜索结果 Web 部件中的词干分解

词干分解是指查询中的名词和形容词扩展为可能的不同变形。 例如,如果某人在查询中输入英文单词 "foot",将会自动扩展为 {"feet"}。 类似地,单词 "overview" 会扩展为 {"overviews"}。

禁用搜索结果 Web 部件中的词干分解

  1. 确认执行此过程的用户帐户是企业搜索中心网站上 SharePoint 组“Designers”的成员。

  2. 在搜索结果页上,单击"设置"菜单,然后单击"编辑页面"。

  3. 在“搜索结果”Web 部件中,单击“ 搜索结果 Web 部件菜单” 箭头,单击“ 导出...”,然后将 Web 部件保存到计算机。

  4. 在文本编辑器(例如,记事本)中打开 Web 部件。

  5. 将"EnableStemming"的值更改为"false",然后使用新名称(例如,Search_Results_NoStemming.webpart)保存文件。

  6. 在搜索结果页上的"主区域"中,单击"添加 Web 部件"。

  7. 在"类别"部分,单击"上载 Web 部件"箭头。

  8. 在"上载 Web 部件"部分,单击"浏览"以查找已编辑的 Web 部件文件,然后单击"上载"。

  9. 要向搜索结果页添加自定义的"搜索结果 Web 部件",请执行以下操作:

  • 浏览到搜索结果页。

  • 单击“设置”菜单,然后单击“编辑页面”

  • 在要添加 Web 部件的 Web 部件区域中,单击"添加 Web 部件"。

  • 在"类别"列表中,选择"已导入的 Web 部件"。

  • 在"部件"列表中,选择要上载的 Web 部件,然后单击"添加"。

  1. 要从搜索结果页删除默认搜索结果 Web 部件,请执行以下操作:
  • 浏览到搜索结果页。

  • 单击“设置”菜单,然后单击“编辑页面”

  • 在 Web 部件中,单击"搜索结果 Web 部件"菜单箭头,然后单击"删除"。

注意

禁用词干分解会关闭所有语言的这一功能,以下语言除外:阿拉伯语、爱沙尼亚语、芬兰语、希伯来语、匈牙利语、朝鲜语、拉脱维亚语和斯洛伐克语。

另请参阅

SharePoint Server 中的查询变量

在 SharePoint Server 中配置搜索的结果源

在 SharePoint Server 中规划查询转换和结果排序

博客系列:如何更改搜索结果在 SharePoint Server 2013 中的显示方式