在 SharePoint Server 中設定精簡搜尋網頁組件的屬性Configure properties of the Refinement Web Part in SharePoint Server

摘要: 了解如何設定「精簡搜尋」網頁組件的屬性、如何顯示精簡器計數,以及如何變更精簡器顯示名稱。Summary: Learn how to configure properties of the Refinement Web Part, how to display refiner counts, and how to change the refiner display name.

根據預設,所有搜尋類別頁面 (results.aspx、peopleresults.aspx、conversationresults.aspx、videoresults.aspx) 上都會使用「精簡搜尋」網頁組件。此網頁組件會將來自「搜尋結果」網頁組件的搜尋結果篩選分類,幫助使用者精簡搜尋結果,找出真正想要的資料。您可以透過變更「精簡搜尋」網頁組件中的屬性來達成下列目標:By default, the Refinement Web Part is used on all search vertical pages (results.aspx, peopleresults.aspx, conversationresults.aspx, videoresults.aspx). The Web Part filters search results from a Search Results Web Part into categories to help users narrow search results to help them find what they are looking for. By changing properties in the Refinement Web Part you can you can do the following:

  • 指定篩選來自不同「搜尋結果」網頁組件的搜尋結果。Specify a different Search Results Web Part from which to filter search results.

  • 指定要顯示在網頁組件中的精簡器。Specify which refiners to show in the Web Part.

  • 變更每個精簡器所套用的顯示範本。Change the display template that is applied to each refiner.

開始這些程序之前,請先確認下列事項:Before you begin these procedures, verify the following:

  • 您想要用來作為精簡器的 Managed 屬性,已在搜尋結構描述中設為是可精簡和可查詢的。您可以檢視或編輯 Managed 屬性的 [主要特性]**** 以驗證或變更此設定,如<新增 Managed 屬性>所述。The managed properties that you want to use as refiners are set to refinable and queryable in the search schema. You can verify or change this by viewing or editing the Main characteristics of the managed property as described in To add a managed property.

  • 已對包含 Managed 屬性 (其已啟用為精簡器) 的內容來源進行完整編目 (如<Start, pause, resume, or stop a crawl in SharePoint Server>中所述)。You have done a full crawl of the content source that contains the managed properties that are enabled as refiners as described in Start, pause, resume, or stop a crawl in SharePoint Server.

設定精簡搜尋網頁組件的屬性Configure properties of the Refinement Web Part

設定精簡搜尋網頁組件的屬性To configure the properties of a Refinement Web Part

  1. 確認執行此程序的使用者帳戶為企業搜尋中心網站上設計者 SharePoint 群組的成員。Verify that the user account that performs this procedure is a member of the Designers SharePoint group on the Enterprise Search Center site.

  2. 瀏覽至包含欲設定之精簡搜尋網頁組件的頁面。Browse to the page that contains the Refinement Web Part that you want to configure.

  3. 按一下 [設定]**** 功能表,然後按一下 [編輯頁面]*Click the *Settings menu, and then click Edit Page.

  4. 在網頁組件中,按一下 [精簡搜尋網頁組件功能表]**** 箭頭,然後再按一下 [編輯網頁組件]*In the Web Part, click the *Refinement Web Part Menu arrow, and then click Edit Web Part.

  5. 在 [網頁組件] 工具窗格的 [精簡搜尋目標]**** 區段中,選取要篩選從其得來之搜尋結果的網頁組件。預設會選取「搜尋結果」網頁組件。In the Web Part tool pane, in the Refinement Target section, select the Web Part from which from which to filter search results. By default, the Search Results Web Part is selected.

  6. 在 [網頁組件] 工具窗格中,確認已選取 [選擇此網頁組件中的精簡器]*In the Web Part tool pane, verify that the *Choose Refiners in this Web Part is selected.

  7. 按一下 [選擇精簡器]*Click *Choose Refiners.

  8. 在 [精簡搜尋設定]**** 頁面的 [可用的精簡器]**** 區段中,使用按鈕選取要顯示在網頁組件中的精簡器,以及這些精簡器的顯示順序。若您已為可精簡的 Managed 屬性指定「別名」*,此別名會顯示在 [設定]* 區段中。On the Refinement configuration page, from the Available refiners section, use the buttons to select which refiners should be shown in the Web Part, and also in what order that they should be shown. If you have specified an Alias for a refinable managed property, this alias is shown in the Configuration for section.

  9. 在 [設定]**** 區段中,設定每一個精簡器的顯示方式。In the Configuration for section, configure how you want each refiner to appear.

    注意

    若您具備的是單一語言的網站,即可在 [顯示名稱]**** 區段中變更精簡器的顯示名稱。若是多語系網站,就必須依據<變更精簡器顯示名稱>中所述,變更精簡器顯示語言。If you have a single language site, you can change the refiner display name in the Display name section. For multilingual sites, you have to change the refiner display language as described in Change the refiner display name.

變更精簡器顯示名稱Change the refiner display name

根據預設,系統會使用已啟用為精簡器之 Managed 屬性的名稱,做為該精簡器的顯示名稱。許多時候,Managed 屬性名稱對使用者來說並不容易懂,例如 RefinableString00 或 ColorOWSTEXT。您可以變更主版頁面圖庫中的 java 指令碼檔案,以變更精簡器的顯示名稱。By default, the name of the managed property that is enabled as a refiner will be used as display name for the refiner. In many cases, the managed property name is not user-friendly — for example, RefinableString00 or ColorOWSTEXT. You can change the display name of the refiner by changing a java script file in the master page gallery.

變更精簡器顯示名稱To change the refiner display name

  1. 確認執行此程序的使用者帳戶為企業搜尋中心網站上設計者 SharePoint 群組的成員。Verify that the user account that performs this procedure is a member of the Designers SharePoint group on the Enterprise Search Center site.

  2. 在 [設定]**** 功能表上,按一下 [網站設定]*On the *Settings menu, click Site Settings.

  3. 在 [網站設定]**** 頁面的 [網頁設計工具庫]**** 區段中,按一下 [主版頁面與版面配置]*On the *Site Settings page, in the Web Designer Galleries section, click Master pages and page layouts.

  4. 在 [主版頁面圖庫]**** 頁面上,按一下 [顯示範本]*On the *Master Page Gallery page, click Display Templates.

  5. 在 [顯示範本]**** 頁面上,按一下 [語言檔案]*On the *Display Templates page, click Language Files.

  6. 在 [語言檔案]**** 頁面上,按一下資料夾,其中包含您要用來變更精簡器顯示名稱的語言。On the Language Files page, click the folder that contains the language for which you want to change the refiner display name.

  7. 開啟 CustomStrings.js 檔案。Open the CustomStrings.js file.

  8. 在檔案中,使用下列語法,針對已啟用為精簡器 (您想要變更其顯示名稱) 的每一個 Managed 屬性,各新增一行:Add one line to the file for each managed property that is enabled as a refiner for which you want to change the display name by using the following syntax:

    "rf_RefinementTitle_ManagedPropertyName": "Sample Refinement Title for ManagedPropertyName"

    例如,您可新增下列字行,將 Managed 屬性 RefinableInt00 的顯示名稱變更為 Price:For example, you can add the following line to change the display name for the managed property RefinableInt00 to Price:

    "rf_RefinementTitle_RefinableInt00": "Price".

新增精簡器計數至精簡搜尋網頁組件Add refiner counts to the Refinement Web Part

根據預設,「精簡搜尋」網頁組件不會顯示精簡器計數 (亦即每個精簡器值的項目數)。例如,若您已啟用 Managed 屬性 Color 做為精簡器,精簡器值只會顯示 Red、Green、Blue 等顏色。您可變更 HTML 檔案中的值來加上精簡器計數,讓精簡器值顯示為 Red (10)、Green (12) 和 Blue (8)。By default, the Refiner Web Part will not show refiner counts — that is, the number of items for each refiner value. For example, if you have enabled the managed property Color as a refiner, the refiner values will only show colors such as Red, Green, and Blue. You can add refiner counts by changing a value in an HTML file so that the refiner values are shown as Red (10), Green (12), and Blue (8).

新增精簡器計數至精簡搜尋網頁組件To add refiner counts to the Refinement Web Part

  1. 確認執行此程序的使用者帳戶為企業搜尋中心網站上設計者 SharePoint 群組的成員。Verify that the user account that performs this procedure is a member of the Designers SharePoint group on the Enterprise Search Center site.

  2. 在 [設定]**** 功能表上,按一下 [網站設定]*On the *Settings menu, click Site Settings.

  3. 在 [網站設定]**** 頁面的 [網頁設計工具庫]**** 區段中,按一下 [主版頁面與版面配置]*On the *Site Settings page, in the Web Designer Galleries section, click Master pages and page layouts.

  4. 在 [主版頁面圖庫]**** 頁面上,按一下 [顯示範本]*On the *Master Page Gallery page, click Display Templates.

  5. 在 [顯示範本]**** 頁面上,按一下 [篩選]*On the *Display Templates page, click Filters.

  6. 開啟 Filter_Default.html 檔案。Open the Filter_Default.html file.

  7. ShowCounts 的值變更為 trueChange the value for ShowCounts to true.

  8. 儲存檔案。Save the file.