如何設定搜尋結果網頁組件以使用 SharePoint Server 中的新結果來源How to configure the Search Results Web Part to use a new result source in SharePoint Server

摘要:了解如何設定搜尋結果網頁組件以使用 SharePoint Server 中的新結果來源。Summary: Learn how to configure the Search Results Web Part to use a new result source in SharePoint Server.

在這一系列、如何建立搜尋中心網站集合及啟用 SharePoint Server 的內容編目,先前文章中我們將說明如何建立搜尋中心網站集合及啟用內容編目。在本文中,您將了解:In the previous article in this series, How to create a Search Center Site Collection and enable crawling of your content in SharePoint Server, we explained how you can create a Search Center Site Collection and enable crawling of your content. In this article, you'll learn:

如何關閉頁面庫的版本設定How to turn off versioning for the Pages library

如果您不想再存回及取出頁面,設定搜尋結果網頁組件時,您可以關閉頁面庫的版本設定。If you don't want to check pages in and out when you configure the Search Results Web Part, you can turn off versioning for the Pages library.

若要關閉的頁面庫版本設定的步驟如下:Here are the steps to turn off versioning for the Pages library:

  1. 移至 [網站設定 --> 網站內容]Go to Site settings --> Site contents.

  2. 在 [網站內容] 頁面上,按一下 [頁面庫。On the Site Contents page, click the Pages library.

  3. 頁面庫中,按一下 [文件庫] 索引標籤和 [文件庫設定]。In the Pages library, click the LIBRARY tab and then Library Settings.

  4. 在 [設定] 頁面上按一下 [版本設定]。On the Settings page, click Versioning settings.

  5. 在 [版本設定] 頁面上 [內容核准] 區段中的需要核准內容的送出的項目,請選取 [On the Versioning Settings page, in the Content Approval section, for Require content approval for submitted items, select No.

  6. [文件版本歷程記錄] 區段中的建立每當您編輯此文件庫中的檔案版本、 選取 [無版本設定]。In the Document Version History section, for Create a version each time you edit a file in this document library, select No versioning.

  7. 要求取出] 區段中的要求之前可加以編輯已取出的文件,請選取 [In the Require Check Out section, for Require documents to be checked out before they can be edited, select No.

    關閉頁面庫的版本設定

您應該考慮建立搜尋中心的結果來源Why you should consider creating a result source for your Search Center

結果來源指定搜尋結果可以來自其中。例如,在我們的案例中,我們沒有不想看從 SharePoint 伺服器陣列內的所有網站,但只能從一個伺服器陣列內的特定網站的搜尋結果。A result source specifies where your search results can come from. For example, in our scenario, we did not want search results to come from all sites within the SharePoint farm, but only from one specific site within the farm.

在搜尋中心的預設結果來源傳回完整的 SharePoint 伺服器陣列搜尋結果。如果您想從完整的 SharePoint 伺服器陣列的搜尋結果,您可以移至下一篇文章在這一系列規劃使用 SharePoint Server 中的搜尋結果頁面上的精簡器。但是,如果您想從子集合的搜尋結果 (在我們案例中,一個特定的網站) SharePoint Server 伺服器陣列中,您應建立結果來源。The default result source in a Search Center returns search results from the complete SharePoint Server farm. If you want search results from the complete SharePoint Server farm, you can go to the next article in this series, Plan to use refiners on a search results page in SharePoint Server. But, if you want search results from only a subset within your SharePoint Server farm (in our scenario, one specific site), you should create a result source.

如何建立結果來源How to create a result source

根據您的權限層級,您可以建立結果來源在三層級:Depending on your permission level, you create a result source on three levels:

權限等級Permission level 要新增的結果來源Where the result source will be added
Search Service 應用程式管理員Search service application administrator
伺服器陣列內的所有網站集合To all site collections within the farm
網站集合管理員Site collection administrator
若要在網站集合中的所有網站To all sites in a site collection
網站集合擁有者Site collection owner
在單一站台To a single site

若要儲存空間,我們將只顯示如何建立網站集合管理員的結果來源。To save space, we'll only show you how to create a result source as a Site collection administrator.

  1. 移至 [網站設定 --> 搜尋結果來源Go to Site settings --> Search Result Sources.

  2. 在 [管理結果來源] 頁面上按一下 [新增結果來源]。On the Manage Result Sources page, click New Result Source.

    建立結果來源

  3. 在 [新增結果來源] 頁面上輸入的名稱通訊協定類型] 中選取值,並再按一下 [啟動查詢產生器。這會開啟一個對話方塊。On the Add Result Source page, enter a Name. Select values for Protocol and Type, and then click Launch Query Builder. This opens a dialog box.

    在我們的案例中,我們將名為結果來源的文章、 並保留預設值為通訊協定及類型。In our scenario, we named the result source Articles , and kept the default values for Protocol and Type.

    新增結果來源

  4. 在 [建立您的查詢] 對話方塊中,定義的結果來源。In the Build Your Query dialog box, define the result source.

    請記住,我們的案例中我們只想來自伺服器陣列內的特定網站的搜尋結果。因此,在 [查詢文字] 欄位中我們新增下列:Remember, in our scenario we only wanted search results to come from a particular site within the farm. Therefore, in the Query text field we added the following:

    {searchTerms?} (contentclass:sts_listitem) path:http://<path>
    

    來自特定網站的搜尋結果

    我們繼續之前,我們分析我們的輸入:Before we move on, let's analyze what we entered:

    • {searchTerms?}在我們的結果來源,我們想要包含在查詢內部使用者類型] 方塊時再搜尋的某個項目。做了明顯改善我們有不知道哪些使用者將類型的方式。因此,我們新增{searchTerms?}查詢變數。順便一提,您可以分清很查詢變數因為它必須被包圍在大括號 (如需詳細資訊,請參閱 < Query variables in SharePoint Server)。當使用者輸入查詢時,使用者已經在 [查詢] 方塊中輸入文字會取代此查詢變數。變數的結尾問號表示如果在 [查詢] 方塊中不輸入任何文字時,應該會忽略此變數。{searchTerms?} In our result source, we wanted to include the words that users type inside the query box when then search for something. Obviously we have no way to know what users will type. Therefore, we added the {searchTerms?} query variable. By the way, you can tell it is a query variable because it is enclosed in braces (for more information, see Query variables in SharePoint Server). When a user enters a query, this query variable is replaced by the words the user has typed in the query box. The question mark at the end of the variable means that if no words are entered in the query box, the variable should be ignored.

    • (contentclass:sts_listitem)這表示僅清單項目將會包含在結果來源。(contentclass:sts_listitem) This means that only list items will be included in the result source.

    • path:http://<path>這是從我們想要搜尋結果來自網站的路徑。path:http://<path>This is the path of the site from where we wanted search results to come from.

  5. 按一下 [測試] 索引標籤] 和 [顯示更多正確運作的結果來源的測試。Test that the result source is working correctly by clicking the TEST tab, and then Show more.

    測試並顯示更多

  6. {SearchTerms} ] 欄位中輸入要模擬使用者輸入查詢的查詢文字和 [測試查詢]In the {searchTerms} field, enter Query words to simulate a query entered by a user, and then click Test query.

    在我們的案例中,我們輸入搜尋設定In our scenario, we entered search configuration .

    輸入查詢

    52 結果所傳回的通知。(我將會告訴您為何此為種類的相當酷中的 [下一步] 區段中...)。Notice that 52 results were returned. (I will tell you why this is kind of cool in the next section…).

  7. 按一下 [確定] 關閉對話方塊],然後儲存Click OK to close the dialog box, and then Save.

因此,現在我們已在搜尋中心的結果來源,我們可以移至設定搜尋結果網頁組件以使用新的結果來源。So now that we have a result source for the Search Center, we can move on to configuring the Search Results Web Part to use the new result source.

如何設定搜尋結果網頁組件以使用新的結果來源How to configure the Search Results Web Part to use a new result source

根據預設,搜尋結果網頁組件會使用搜尋結果頁面上。若要設定搜尋結果網頁組件,您必須瀏覽至 [搜尋結果頁面。以下是您必須:By default, the Search Results Web Part is used on the search results page. To configure the Search Result Web Part, you have to navigate to the search results page. Here's what you have to do:

  1. 在搜尋中心首頁] 頁面 (此頁面的預設 URL 是<網站>/Pages/default.aspx ),在 [搜尋] 方塊中輸入查詢並按EnterOn your Search Center home page (the default URL to this page is <site>/Pages/default.aspx ), enter a query in the search box, and press Enter.

    在我們的案例中,我們輸入搜尋設定In our scenario, we entered search configuration .

    輸入搜尋

    當您按下Enter時,您將會前往搜尋結果頁面 (此頁面的預設 URL 是<網站>/Pages/results.aspx )。When you press Enter, you'll be taken to the to the search results page (the default URL to this page is <site>/Pages/results.aspx ).

    在我們的案例中,所傳回的 1,051 搜尋結果。In our scenario, 1,051 search results were returned.

    預設搜尋結果頁面

    請記住,依預設您將取得搜尋結果從完整的 SharePoint 伺服器陣列。下列步驟說明如何變更此設定讓您新建立的結果來源的唯一搜尋結果會傳回。Remember, by default you'll get search results from the complete SharePoint Server farm. The following steps explain how to change this so only search results from your newly-created result source are returned:

  2. 在 [搜尋結果] 頁面上按一下 [設定] 功能表--> [編輯頁面]On the search results page, click the Settings menu --> Edit Page.

  3. 搜尋結果網頁組件[網頁組件功能表] 和 [編輯網頁組件In the Search Results Web Part, click the Web Part Menu, and then click Edit Web Part.

    按一下編輯網頁組件

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

    變更查詢

  5. 在對話方塊中,從[選取查詢] 功能表選取新建立結果來源。In the dialog box, from the Select a query menu, select your newly-created result source.

    在我們的案例中,選取 [文章 (網站集合)的結果來源。In our scenario, we selected the Articles (Site Collection) result source.

    選取新結果來源

  6. 按一下對話方塊中的[確定] 、 [網頁組件工具窗格] 中按一下 [確定] ,然後儲存] 頁面。若要驗證組態運作,輸入查詢。Click OK in the dialog box, click OK in the Web Part Tool pane, and then save the page. To verify that the configuration is working, enter a query.

    在我們的案例中,我們輸入搜尋設定In our scenario, we entered search configuration .

    最終搜尋結果

    所傳回的 52 結果,這是相同的我們測試查詢的結果來源設定時所傳回的項目數。很酷吧吗?52 results were returned, which is the same number of items that were returned when we tested the query in the result source configuration. Pretty cool, huh?

現在搜尋結果網頁組件顯示我們感興趣的搜尋結果下, 一個工作是以方便使用者所使用的精簡器篩選這些搜尋結果。Now that the Search Results Web Part displays the search results we are interested in, the next task is to make it easier for users to filter these search results by using refiners.

本系列中的下一篇文章Next article in this series

規劃 SharePoint Server 中的搜尋結果頁面上使用精簡器Plan to use refiners on a search results page in SharePoint Server