如何將自訂的搜尋類別新增至 SharePoint Server 中的搜尋結果頁面How to add a custom search vertical to your search results page in SharePoint Server

摘要:了解如何將自訂的搜尋類別新增至您在 SharePoint Server 中的結果頁面。Summary: Learn how to add a custom search vertical to your results page in SharePoint Server.

這一系列、如何新增精簡器新增到 SharePoint Server 中的搜尋結果頁面,在先前文章中我們顯示您如何新增並設定精簡搜尋結果頁面上。本文中您將了解:In the previous article in this series, How to add refiners to your search results page in SharePoint Server, we showed you how to add and configure refiners for your search results page. In this article you'll learn:

使用日常情況中之搜尋類別Using a search vertical in an everyday situation

您可能不聽詞"垂直式搜尋 」 前,但可能使用它們好幾次。我們看接近我們所謂的 「 搜尋垂直。 」 的字詞You may not have heard the term "search vertical" before, but it's likely you have used them several times. Let's take a closer look at what we mean by the term "search vertical."

假設您享受滑雪,所以您通常搜尋 ski 相關的內容。當您輸入的字"ski"搜尋引擎中時,您就會取得許多搜尋結果。Suppose you enjoy skiing, so you often search for ski-related content. When you enter the word "ski" in a search engine, you get many search results.

搜尋類別 Web

您是很高興查看有太多資訊向外有滑雪,但在此例中您要只尋找更好的 ski 圖片。這是可使用的搜尋類別。You are delighted to see there is much information out there about skiing, but in this case, you are just looking for great ski pictures. This is where search verticals can be used.

在相同的搜尋結果頁面] 按一下圖像,並立即在您的螢幕填滿的彩色衣服中的人員從清除藍天 racing 停機時的陽光游泳白色斜坡圖像。Wow !On the same search results page, you click IMAGES, and in an instant your screen is filled with images of people in colorful clothing, racing down white slopes while bathing in sunshine from a clear blue sky. Wow!


當您按一下 [圖像] 時所使用之搜尋類別。Bing 有五個搜尋類別:網頁伺服器、影像影片地圖,與新聞When you click IMAGES, you are using a search vertical. Bing has five search verticals: WEB, Images, VIDEOS Maps, and NEWS.


搜尋類別來篩選搜尋結果因此只有特定類型的搜尋結果的顯示。我們按一下圖像搜尋類別,因此唯一的圖像所顯示已篩選的搜尋結果。A search vertical filters search results so only a certain type of search results are displayed. When we clicked the IMAGES search vertical, the search results were filtered so only images were displayed.

關於 SharePoint Server 中的搜尋類別About search verticals in SharePoint Server

在 SharePoint Server 搜尋類別會顯示在搜尋導覽網頁組件。有四個預設搜尋類別:每個項目人員對話影片In SharePoint Server, search verticals are displayed in the Search Navigation Web Part. There are four default search verticals: Everything, People, Conversations, and Videos.


當使用者按一下其中一個這些搜尋類別時,其事實上移至新的頁面。例如,預設搜尋結果頁面上,每個項目] 搜尋類別,使用results.aspx頁面。When users click one of these search verticals, it will in fact move to a new page. For example, the default search results page, the Everything search vertical, uses the results.aspx page.


當使用者按一下 [人員] 搜尋類別時,瀏覽至 [ peopleresults.aspx ] 頁面上。When a user clicks on the People search vertical, they navigate to the peopleresults.aspx page.


以下是所用的四個搜尋類別的預設頁面:The following are the default pages that are used for the four search verticals:

垂直式搜尋Search vertical 使用此頁面Use this page

若要檢視這些頁面中,從 [網站設定] 功能表選取 [網站內容 --> 頁面To view these pages, from the Site settings menu, select Site contents --> Pages.


所有的預設類別頁面使用這些網頁組件:The default vertical pages all use these Web Parts:


  1. 精簡搜尋網頁組件Refinement Web Part

  2. 搜尋方塊網頁組件Search Box Web Part

  3. 搜尋導覽網頁組件Search Navigation Web Part

  4. 搜尋結果網頁組件Search Results Web Part

這些頁面之間的差異在於如何設定搜尋結果網頁組件。若要為特定: 網頁組件設定為使用不同的結果來源The difference between these pages is how the Search Results Web Part is configured. To be specific: the Web Parts are configured to use different result sources .

結果來源-為何設定的限制是個好方法Result sources - why setting limits is a good thing

舊版文章所述,將結果來源會指定搜尋結果可以從中甚至的來源。例如,假設您的搜尋索引的 cube 包含四個結果來源下圖所示:As explained in an earlier article, a result source specifies the source from which your search results can come. For example, suppose that your search index is the cube as shown in the following diagram, where you have four result sources:

  • 結果來源 1: 搜尋結果可以來自完整的 cube。Result source 1: search results can come from the complete cube.

  • 結果來源 2: 搜尋結果只可以來自 Bs。Result source 2: search results can come only from the Bs.

  • 結果來源 3: 搜尋結果只可以來自 Cs。Result source 3: search results can come only from the Cs.

  • 結果來源 4: 搜尋結果只可以來自 Ds。Result source 4: search results can come only from the Ds.

搜尋類別 Cube

讓您限制從搜尋結果可以來自位置,您可以讓更容易找到他們所尋找的使用者。So, by limiting from where search results can come from, you can make it easier for your users to find what they're looking for.

在我們內部搜尋中心案例中,所有搜尋結果都所代表的媒體檔案,例如文章、 圖像或程序的影片類型的清單項目。我們想要建立的三種特定類型的媒體檔案的三個自訂的搜尋類別:In our internal search center scenario, all search results are list items that represent a type of media file, for example an article, an image or a video. We wanted to create three custom search verticals for three specific types of media files:

  • 代表圖像藝術: 清單項目Art: list items that represent images

  • 影片: 清單項目代表影片Video: list items that represent videos

  • 代表互通文章 (互通文章是我們所產生的文章的特定類型) 的 interop: 清單項目Interop: list items that represent interoperable articles (interoperable articles are a specific type of article we produce)

但是,我們可以開始建立這些搜尋類別之前,我們需要建立一個結果來源的每個自訂的搜尋類別。我們會顯示您如何在如何建立結果來源中建立結果來源。But, before we could begin to create these search verticals, we had to create one result source for each custom search vertical. We showed you how to create a result source in How to create a result source.

這是我們所藝術結果來源的定義。This is how we defined the Art result source .


請記住,{searchTerms?}(contentclass:sts_listitem) path:http://<path>已稍早建立的文章結果來源的查詢文字。這樣一來,我們新增AND ContentType:ArtRemember, {searchTerms?}(contentclass:sts_listitem) path:http://<path> was the query text of the Article result source that we created earlier. To this, we added AND ContentType:Art

在我們的清單,我們會使用網站欄內容類型指定不同的媒體檔案。例如,所有圖像都具有值美工圖案內容類型。In our lists, we use the site column Content Type to specify the different media files. For example, all images have the value Art for Content Type .


如此,透過新增AND ContentType:Art至查詢的文字,只列出具有值藝術師內容類型將會傳回搜尋結果中的項目。So, by adding AND ContentType:Art to the query text, only list items that have the value Art for Content Type will be returned in search results.

以下是我們所建立的三個新結果來源。Here are the three new result sources we created.


現在,我們需要三個新的結果來源,我們可以開始建立自訂的搜尋類別。Now that we had three new result sources, we could move on to creating the custom search verticals.

如何建立自訂的搜尋類別How to create a custom search vertical

當您建立自訂的搜尋類別時,最先進行的您必須執行動作會建立要使用的搜尋類別頁面。若要建立新頁面的步驟如下:When you create a custom search vertical, the first thing that you must do is to create a page the search vertical will use. Here are the steps to create a new page:

  1. 從 [網站設定] 功能表選取 [網站內容]。From the Site Settings menu, select Site contents.


  2. 選取 [頁面]。Select Pages.

  3. 頁面庫中,選取 [檔案] 索引標籤-->新增文件 --> ] 頁面In the Pages library, select the FILES tab --> New Document --> Page.


  4. 在 [建立頁面] 頁面上輸入標題URL 名稱On the Create Page page, enter a Title and a URL Name.

    在我們的案例中,我們輸入美工圖案美工圖案In our scenario, we entered Art and art .


  5. 按一下 [建立]。Click Create.

    在新頁面會顯示在頁面庫。Your new page is displayed in your Pages library.


    既然您自訂的搜尋類別有] 頁面上,您可以開始建立實際的搜尋類別。以下是您應該執行的動作:Now that you have a page for your custom search vertical, you can begin to create the actual search vertical. Here's what you should do:

  6. 在 [網站設定] 頁面上按一下 [搜尋設定]。On the Site Settings page, click Search Settings.


  7. 在 [搜尋設定] 頁面上的 [設定搜尋導覽] 區段中按一下 [新增連結]。On the Search Settings page, in the Configure Search Navigation section, click Add Link.


  8. 在 [導覽連結] 對話方塊的 [標題] 欄位中輸入搜尋直排標題。此文字會顯示為您的搜尋結果頁面上的"] 索引標籤"名稱。In the Navigation Link dialog box, in the Title field, enter the search vertical title. This text will appear as the "tab" name on your search results page.

    在我們的案例中,我們輸入美工圖案In our scenario, we entered Art .


  9. 在 [ URL ] 欄位中選取 [瀏覽並選取您的搜尋類別的頁面。In the URL field, select Browse and select a page for your search vertical.

    在我們的案例中,選取 [我們剛才建立 [美工圖案] 頁面。In our scenario, we selected the art page we just created.

    URL 美工圖案

  10. 按一下[確定]以關閉 [導覽連結] 對話方塊] 方塊中。Click OK to close the Navigation Link dialog Box.

  11. 在 [搜尋設定] 頁面中設定搜尋導覽] 區段中,選取您不想以顯示,然後按一下 [刪除的搜尋類別。On the Search Settings page, in the Configure Search Navigation section, select the search verticals that you don't want to display, and then click Delete.

    在我們的案例中,我們已刪除的人員對話影片的類別,讓我們已僅左與每個項目藝術師加入搜尋類別。In our scenario, we deleted the People, Conversations, and Videos verticals so that we were only left with the Everything and the Art search vertical.


  12. 按一下[確定]儲存的所有修訂。Click OK to save all changes.

  13. 在您的搜尋中心] 中輸入查詢。在您搜尋結果] 頁面會顯示您新建立的搜尋類別。In your Search Center, enter a query. On your search results page, your newly created search vertical is displayed.

    在我們搜尋結果] 頁面上顯示圖案垂直。On our search results page, the Art vertical was displayed.


  14. 在搜尋結果] 頁面上按一下 [在您新建立的搜尋類別,並確認 URL 是相同當您在步驟 4 指定。On your search results page, click on your newly created search vertical, and verify that the URL is the same as you specified in step 4.

    在我們的案例中,我們在按一下圖案,並確認 URL 是否已<網站>/articles/Pages/art.aspx 。我們也注意到已顯示 13 搜尋結果。In our scenario, we clicked Art , and verified that the URL was <site>/articles/Pages/art.aspx . We also noticed that 13 search results were displayed.


  15. 在您新搜尋類別] 頁面上,選取 [編輯] 頁面上,然後編輯搜尋結果網頁組件On your new search vertical page, select to edit the page, and then to edit the Search Results Web Part.

  16. 在 [網頁組件工具] 頁面中按一下 [變更查詢]。這會開啟一個對話方塊。In the Web Part tool page, click Change query. This opens a dialog box.


  17. 在 [建立您的查詢] 對話方塊中,從[選取查詢] 功能表選取剛才 (什麼我們進行了上一節) 此搜尋類別的結果來源。In the Build Your Query dialog box, from the Select a query menu, select the result source that you created for this search vertical (what we did in the previous section).

    在我們的案例中,選取 [藝術結果來源 (網站集合)In our scenario, we selected Art result source (Site Collection) .


  18. 按一下 [確定]並儲存] 頁面。Click OK and save the page.

    在您新搜尋類別] 頁面上輸入確認有顯示正確的搜尋結果的查詢。On your new search vertical page, enter a query to verify that the correct search results are displayed.

    在我們的案例中,我們再次輸入聯合航空並注意到已顯示 [僅限 11 搜尋結果。請記住,我們已變更在搜尋結果網頁組件中的結果來源之前,已顯示 13 的結果。讓我們新類別所運作。好 !In our scenario, we entered united airlines again, and noticed that only 11 search results were displayed. Remember, before we changed the result source in the Search Result Web Part, 13 results were displayed. So our new vertical was working. Nice!


    在我們的案例中,我們會新增兩個更多的搜尋類別、視訊Interop 。與這,我們有完成設定 「 搜尋中心。In our scenario, we added two more search verticals, Video and Interop . And with that, we had completed the Search Center set up.


您可以執行的動作已成功設定 「 搜尋中心之後What you can do after you have successfully set up a Search Center

當您已成功設定搜尋中心時、 最先進行的應該做的是 congratulate 自行上也可以完成的工作 !好工作 !When you have successfully set up a Search Center, the first thing that you should do is congratulate yourself on a job well done! Nice job!

但是,工作通常不會結束此處。若要在搜尋中心更為容易記住,您可以變更搜尋結果的顯示的方式,例如專屬於您的公司或商務顯示資訊。您可以了解如何執行的作業數列如何變更 SharePoint Server 中的搜尋結果顯示的方式But, the job usually doesn't end here. To make the Search Center even more user-friendly, you can change the way search results are displayed, for example to display information that is specific to your company or business. You can read about how to do that in series How to change the way search results are displayed in SharePoint Server.