Share via


在 SharePoint Server 中設定精簡搜尋網頁組件的屬性

適用于:yes-img-132013 yes-img-16 2016yes-img-192019 yes-img-se訂閱版本 no-img-sopMicrosoft 365 中的 SharePoint

根據預設,所有搜尋類別頁面 (results.aspx、peopleresults.aspx、conversationresults.aspx、videoresults.aspx) 上都會使用「精簡搜尋」網頁組件。 此網頁組件會將來自「搜尋結果」網頁組件的搜尋結果篩選分類,幫助使用者精簡搜尋結果,找出真正想要的資料。 藉由變更 Refinement 網頁元件中的屬性,您可以執行下列動作:

  • 指定篩選來自不同「搜尋結果」網頁組件的搜尋結果。

  • 指定要顯示在網頁組件中的精簡器。

  • 變更每個精簡器所套用的顯示範本。

開始這些程序之前,請先確認下列事項:

  • 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>中所述)。

設定精簡搜尋網頁組件的屬性

設定精簡搜尋網頁組件的屬性

  1. 確認執行此程序的使用者帳戶為企業搜尋中心網站上設計者 SharePoint 群組的成員。

  2. 瀏覽至包含欲設定之精簡搜尋網頁組件的頁面。

  3. 按一下 [設定] 功能表,然後按一下 [編輯頁面]

  4. 在網頁組件中,按一下 [精簡搜尋網頁組件功能表] 箭頭,然後再按一下 [編輯網頁組件]

  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. 在 [網頁組件] 工具窗格中,確認已選取 [選擇此網頁組件中的精簡器]

  7. 按一下 [選擇精簡器]

  8. 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. 在 [設定] 區段中,設定每一個精簡器的顯示方式。

    注意事項

    若您具備的是單一語言的網站,即可在 [顯示名稱] 區段中變更精簡器的顯示名稱。 若是多語系網站,就必須依據<變更精簡器顯示名稱>中所述,變更精簡器顯示語言。

變更精簡器顯示名稱

根據預設,系統會使用已啟用為精簡器之 Managed 屬性的名稱,做為該精簡器的顯示名稱。 許多時候,Managed 屬性名稱對使用者來說並不容易懂,例如 RefinableString00 或 ColorOWSTEXT。 您可以變更主版頁面圖庫中的 java 指令碼檔案,以變更精簡器的顯示名稱。

變更精簡器顯示名稱

  1. 確認執行此程序的使用者帳戶為企業搜尋中心網站上設計者 SharePoint 群組的成員。

  2. 在 [設定] 功能表上,按一下 [網站設定]

  3. 在 [網站設定] 頁面的 [網頁設計工具庫] 區段中,按一下 [主版頁面與版面配置]

  4. 在 [主版頁面圖庫] 頁面上,按一下 [顯示範本]

  5. 在 [顯示範本] 頁面上,按一下 [語言檔案]

  6. 在 [語言檔案] 頁面上,按一下資料夾,其中包含您要用來變更精簡器顯示名稱的語言。

  7. 開啟 CustomStrings.js 檔案。

  8. 在檔案中,使用下列語法,針對已啟用為精簡器 (您想要變更其顯示名稱) 的每一個 Managed 屬性,各新增一行:

    "rf_RefinementTitle_ManagedPropertyName": "Sample Refinement Title for ManagedPropertyName"

    例如,您可新增下列字行,將 Managed 屬性 RefinableInt00 的顯示名稱變更為 Price:

    "rf_RefinementTitle_RefinableInt00": "Price".

新增精簡器計數至精簡搜尋網頁組件

根據預設,「精簡搜尋」網頁組件不會顯示精簡器計數 (亦即每個精簡器值的項目數)。 例如,若您已啟用 Managed 屬性 Color 做為精簡器,精簡器值就只會顯示 Red、Green 和 Blue 之類的顏色。 您可變更 HTML 檔案中的值來加上精簡器計數,讓精簡器值顯示為 Red (10)、Green (12) 和 Blue (8)。

新增精簡器計數至精簡搜尋網頁組件

  1. 確認執行此程序的使用者帳戶為企業搜尋中心網站上設計者 SharePoint 群組的成員。

  2. 在 [設定] 功能表上,按一下 [網站設定]

  3. 在 [網站設定] 頁面的 [網頁設計工具庫] 區段中,按一下 [主版頁面與版面配置]

  4. 在 [主版頁面圖庫] 頁面上,按一下 [顯示範本]

  5. 在 [顯示範本] 頁面上,按一下 [篩選]

  6. 開啟 Filter_Default.html 檔案。

  7. ShowCounts 的值變更為 true

  8. 儲存檔案。