了解 SharePoint Server 中的搜尋結果來源Understanding result sources for search in SharePoint Server

摘要: 使用 SharePoint Server 中的結果來源以指定的提供者取得搜尋結果的傳統搜尋經驗,以及選擇性地將搜尋縮小至那些結果的子集。Summary: Use a result source in SharePoint Server to specify a provider to get search results from for the classic search experience, and optionally to narrow a search to a subset of those results.

本文提供 SharePoint Server 中結果來源的簡明概觀。This article provides a brief overview of result sources in SharePoint Server.

重要

SharePoint Server 2019 公用 Preview 現代搜尋體驗預設結果來源取得其結果。The modern search experience in SharePoint Server 2019 Public Preview gets its results from the default result source. 如果您變更預設結果來源它會影響的傳統和現代搜尋經驗。If you change the default result source it impacts both the classic and modern search experiences.

何謂結果來源?What is a result source?

當使用者發出查詢時,搜尋系統會將查詢和「結果來源」建立關聯以提供搜尋結果。結果來源是一種定義,可指定以下每一項:When a user issues a query, the search system associates the query with a result source to provide search results. The result source is a definition that specifies each of the following:

  • 從其取得搜尋結果的搜尋提供者或來源 URL,例如,本機 SharePoint Search 服務的搜尋索引A search provider or source URL to get search results from — for example, the search index of the local SharePoint Search service

  • 用來取得搜尋結果的通訊協定 例如,OpenSearch 通訊協定A protocol to use to get search results — for example, the OpenSearch protocol

  • 可以將來自指定搜尋提供者或 URL 的結果縮小成指定的子集的查詢轉換 例如,具有特定內容類型的子集A query transform, which can narrow results from the given search provider or URL to a specified subset — for example, a subset that has a particular content type

結果來源還可以指定其他設定,例如,向提供者要求結果時使用的驗證方法。A result source can also specify other settings, such as an authentication method to use when requesting results from a provider.

預先設定的結果來源的範例為 "Local Video Results" (本機視訊結果)。此結果來源將本機 SharePoint 搜尋索引指定為提供者,以及將 "Local SharePoint" 指定為通訊協定,並具有查詢轉換以指定,它將只傳回副檔名和視訊 (例如 MP4) 對應的檔案。"Local Video Results" 結果來源供視訊搜尋經驗或預設企業搜尋中心結果頁面上的搜尋類別使用。An example of a pre-configured result source is "Local Video Results". This result source specifies the local SharePoint search index as the provider and "Local SharePoint" as the protocol, and it has a query transform that specifies that it will return only files that have file extensions that correspond to videos, such as MP4. The "Local Video Results" result source is used by the Videos search experience, or search vertical, on the default enterprise Search Center results page.

下列螢幕擷取畫面顯示預設企業搜尋中心結果頁面提供的四種搜尋經驗。使用者從搜尋方塊提交查詢前,可以先選擇其中一種搜尋經驗。The following screen shot shows the four search experiences that are available on a default enterprise Search Center results page. The user can choose one of these search experiences before submitting a query from the search box.

企業搜尋中心預設的搜尋體驗

下表顯示提供給預設企業搜尋中心結果頁面上提供之四種搜尋經驗使用的結果來源。每個搜尋經驗使用不同的結果來源。The following table shows the result sources that are used by the four search experiences that are available on a default enterprise Search Center results page. Each search experience uses a different result source.

搜尋體驗與對應的結果來源Search experiences and corresponding result sources

這種搜尋經驗This search experience 使用這種預先設定的結果來源Uses this preconfigured result source
所有項目Everything 本機 SharePoint 結果Local SharePoint Results
人員People 本機人員結果Local People Results
交談Conversations 交談Conversations
視訊Videos 本機視訊結果Local Video Results

可用的結果來源Available result sources

SharePoint Server 提供 16 種預先設定的結果來源,並在使用 Search Service 應用程式之 Web 應用程式中的所有網站與網站集合中提供使用。下表顯示預先設定的結果來源。您可以從 [管理結果來源] 頁面檢視結果來源的詳細資訊。SharePoint Server provides 16 pre-configured result sources, which are available in all sites and site collections in web applications that consume a Search service application. The pre-configured result sources are shown in the following table. You can view details about result sources from the Manage Result Sources page.

預先設定的結果來源Pre-configured result sources

這種結果來源This result source 在本機 SharePoint 索引中指定這些項目Specifies these items in the local SharePoint index
交談Conversations 微型部落格、新聞摘要文章,以及社群網站中的討論區Discussions in microblogs, newsfeed posts, and community sites
文件Documents Microsoft Office 文件與PDF 文件Microsoft Office documents and PDF documents
符合內容類型的項目Items matching a content type 符合傳入的查詢所指定之內容類型的項目Items that match a content type that the incoming query specifies
符合標記的項目Items matching a tag 符合傳入的查詢所指定之受管理的中繼資料字詞的文件或清單項目Documents or list items that match a managed metadata term that the incoming query specifies
和目前使用者相關的項目Items related to current user 以查詢範本所指定的方式和使用者相關的文件或清單項目Documents or list items that are related to the user in a way that the query template specifies
本機人員結果Local People Results 來自 User Profile Service 應用程式之設定檔資料庫的人員項目People items from the profile database of the User Profile service application
本機報表與資料結果Local Reports and Data Results Excel、Office 資料連線 (ODC)、報表定義語言 (RDL) 項目,或報表庫中的項目Excel, Office Data Connection (ODC), or Report Definition Language (RDL) items, or items in a report library
本機 SharePoint 結果Local SharePoint Results 來自本機 SharePoint 搜尋索引的所有項目,人員項目除外All items from the local SharePoint search index except People items
本機視訊結果Local Video Results 視訊Videos
頁面Pages
圖片Pictures 相片與圖像Photos and images
常用Popular 依檢視計數排序文件與清單項目Documents and list items sorted by view count
最近變更的項目Recently changed items 依修改日期排序的文件與清單項目Documents and list items sorted by Modified date
建議Recommendations 您對傳入的查詢所建議的文件與清單項目Documents and list items that you recommend for the incoming query
WikiWiki SharePoint Wiki 頁面SharePoint wiki pages

在 [管理結果來源] 頁面中,您可以使用下列兩種方式中的任一種建立其他結果來源:From the Manage Result Sources page, you can create other result sources in either of the following two ways:

結果來源通訊協定與 URLResult source protocols and URLs

結果來源指定四個通訊協定中的一個以用來取得搜尋結果,如以下表格所示。A result source specifies one of four protocols to use to get search results, as shown in the following table.

結果來源通訊協定Result source protocols

指定此通訊協定的結果來源A result source that specifies this protocol 從此搜尋提供者取得搜尋結果Gets search results from this search provider
本機 SharePointLocal SharePoint 本機搜尋服務的搜尋索引The search index of the local Search service
遠端 SharePointRemote SharePoint 在另一個伺服器陣列中主控之搜尋服務的搜尋索引The search index of a Search service hosted in another farm
OpenSearch 1.0/1.1OpenSearch 1.0/1.1 使用 OpenSearch 通訊協定以提供搜尋結果的外部搜尋提供者 (例如遠端搜尋引擎或摘要)An external search provider (such as a remote search engine or feed) that uses the OpenSearch protocol to provide search results
ExchangeExchange Exchange Web 服務Exchange Web Services

使用 "Local SharePoint" 以外之通訊協定的結果來源還必須指定從其取得搜尋結果的 URL,如以下表格所示。A result source that uses a protocol other than "Local SharePoint" must also specify a URL from which to get search results, as shown in the following table.

結果來源 URLResult source URLs

使用此通訊協定的結果來源A result source that uses this protocol 必須指定此 URLMust specify this URL
遠端 SharePointRemote SharePoint 遠端 SharePoint Server 伺服器陣列之根網站集合的位址The address of the root site collection of the remote SharePoint Server farm
OpenSearch 1.0/1.1OpenSearch 1.0/1.1 使用 OpenSearch 通訊協定之搜尋提供者的 RSS 摘要 URLThe URL of the RSS feed of a search provider that uses the OpenSearch protocol
ExchangeExchange Exchange Web 服務 URLAn Exchange Web Services URL

誰可以建立結果來源?Who can create result sources?

結果來源可以在 Search Service 應用程式層級、網站集合層級或網站層級建立。如此 Search Service 應用程式管理員、網站集合管理員及網站擁有者便可以建立和使用結果來源,以符合本身提供搜尋結果給使用者的特定要求。例如,當您在 Search Service 應用程式層級建立結果來源時,該結果來源可用於在相同層級建立的任何查詢規則,也可用於針對位於 Web 應用程式 (使用該 Search Service 應用程式) 中之網站集合或網站建立的任何查詢規則。 如需結果來源的層級與權限資訊,請參閱<在 SharePoint Server 中設定搜尋的結果來源>中的<建立結果來源>。Result sources can be created at the Search service application level, site collection level, or site level. This enables Search service application administrators, site collection administrators, and site owners to create and use result sources to meet their specific requirements for providing search results to users. When you create a result source at the Search service application level, for example, the result source is available to any query rule that is created at the same level, and also to any query rule that is created for a site collection or site that is in a web application that consumes that Search service application. For information about levels and permissions for result sources, see Create a result source in Configure result sources for search in SharePoint Server.

指定結果來源用於查詢Specifying a result source to use for a query

查詢在初始時會根據使用者執行查詢的搜尋經驗和結果來源關聯。例如,如果使用者按一下搜尋方塊下方的 [人員]**** (請參閱本文稍早的螢幕擷取畫面) 以指定人員搜尋經驗,查詢會使用 "Local People Results" 結果來源。A query is initially associated with a result source according to the search experience in which the user performs the query. For example, if a user clicks People below a search box (see the screen shot earlier in this article) to specify the People search experience, the query uses the "Local People Results" result source.

搜尋方塊網頁組件一律和特定的搜尋結果網頁組件關聯。當使用者在搜尋方塊中輸入查詢時,搜尋方塊網頁組件會將查詢傳送至關聯的搜尋結果網頁組件。該搜尋結果網頁組件會指定查詢的結果來源;根據預設,此結果來源為 "Local SharePoint Results"。您可以設定不同的結果來源作為預設值。您也可以編輯任何搜尋結果網頁組件以指定不同的結果來源供使用。例如,您可以新增名為 "Reports" 的新搜尋經驗,以及建立搜尋結果頁面以顯示該搜尋經驗的搜尋結果。您接著以可以編輯新 Reports 結果頁面上的預設搜尋結果網頁組件,以指定作為該搜尋經驗的適當結果來源。這種結果來源的範例可以是包含對應至報表之內容類型的 SharePoint 網站。如需詳細資訊,請參閱下列資源:A Search Box Web Part is always associated with a particular Search Results Web Part. When a user types a query in a search box, the Search Box Web Part sends the query to the associated Search Results Web Part. That Search Results Web Part specifies the result source for the query; by default, this result source is "Local SharePoint Results". You can set a different result source as the default. You can also edit any Search Results Web Part to specify a different result source for it to use. For example, you might add a new search experience called "Reports", and create a search results page for displaying search results for that search experience. You could then edit the default Search Results Web Part that is on the new Reports results page to specify an appropriate result source for that search experience. An example of such a result source would be a SharePoint site that contains content types that correspond to reports. For more information, see the following resources:

您可以將搜尋系統設定成在某些條件下,查詢和額外或不同的結果來源關聯。有一個方法是建立查詢規則以顯示來自另一個結果來源的搜尋結果,如果查詢在該結果來源中的執行頻率高於使用者對其執行的結果來源的話。例如,假設使用者對 Conversations 搜尋經驗中的進行查詢 "keynote speech",但該查詢在 Videos 搜尋經驗中則是更常用。在這種情況下,您可以設定一個動作,在個別的結果區塊中同時顯示視訊結果來源的結果。如需詳細資訊,請參閱下列資源:You can configure the search system so that a query becomes associated with an additional or a different result source under certain conditions. One way to do this is to create a query rule that displays search results from another result source if a query is more frequently performed in that result source than in the one that the user performed it on. For example, let's say that a user queries on "keynote speech" in the Conversations search experience but the query is more popular in the Videos search experience. In that case, you could configure an action that also displays results from the Videos result source in a separate result block. For more information, see the following resources:

當您建立查詢規則時,您要在 [管理查詢規則] 頁面指定要套用該規則的結果來源。然後,您可以在 [新增/編輯查詢規則] 頁面的 [內容]**** 區段新增或移除將套用該規則的結果來源。當查詢提交至您設定為適用之結果來源以外的任何結果來源時,規則不會發生作用。例如,如果您要建立只對所要的人員搜尋發生作用的查詢規則,您可以指定 "Local People Results" 作為套用該規則的結果來源。When you create a query rule, on the Manage Query Rules page you specify a result source to which the rule will apply. Then on the Add/Edit Query Rule page, in the Context section, you can add or remove result sources to which the rule will apply. When a query is submitted to any result source other than those that you set as applicable, the rule cannot fire. For example, if you create a query rule that you want to fire only for people searches, you would specify "Local People Results" as the result source to which the rule applies.

使用查詢轉換縮小搜尋結果Narrowing search results by using a query transform

您可以將搜尋系統設定成解譯使用者查詢的意圖,接著對查詢進行相應的修改以提供更符合目標的搜尋結果。其中一個作法是使用每個結果來源之定義的一部分的 [查詢轉換]**** 區段。例如,若要提供 Videos 搜尋經驗,您可以在結果來源中設定查詢轉換,以指定從其取得視訊查詢搜尋結果的 SharePoint 網站。You can configure the search system so that it interprets the intent of user queries and then modifies queries accordingly to provide more targeted search results. One way to do this is to use the Query Transform section that is part of the definition of each result source. For example, to provide a Videos search experience, in the result source you could configure a query transform to specify a SharePoint site from which to get search results for video queries.

您也可以在發出查詢的網頁組件以及在查詢規則中修改查詢。使用者查詢首先由網頁組件中設定的任何修改加以轉換,然後由發生作用的作何查詢規則加以轉換,最後由查詢之結果來源中的查詢轉換加以轉換。查詢規則及結果來源可以接受修改過的查詢作為輸入,然後再修改一次查詢。不過,結果來源對查詢進行的修改不能再進一步加以修改,因為結果來源中的查詢轉換會對查詢做最後的修改。如需詳細資訊,請參閱<在 SharePoint Server 中規劃轉換查詢和順序結果>。You can also modify queries in the Web Part that issues a query, and in query rules. A user query is transformed first by any modifications that were configured in the Web Part, then by any query rules that fire, and finally by the query transform in the result source for the query. The query rules and result sources can take the modified query as input and modify the query again. However, the modifications made to a query by a result source cannot be modified further, because the query transform in a result source modifies the query last. For more information, see Plan to transform queries and order results in SharePoint Server.

每個預先設定的結果來源都使用查詢轉換,藉此提供您如何使用查詢轉換來縮小搜尋結果的範例。在 [管理結果來源] 頁面上,您可以按一下每個結果來源以查看它們如何使用查詢轉換。例如,您可以按一下預先設定的 "Local People Results" 結果來源,來查看它使用下列查詢轉換以提供來自設定檔資料庫的人員相關的結果。Each pre-configured result source uses a query transform and thus provides an example of how you can use a query transform to narrow search results. On the Manage Result Sources page, you can click each result source to see how it uses a query transform. For example, you can click the pre-configured "Local People Results" result source to see that it uses the following query transform to provide people-related results from the profile database:

{?{searchTerms} ContentClass=urn:content-class:SPSPeople}{?{searchTerms} ContentClass=urn:content-class:SPSPeople}

如需詳細資訊,請參閱<在 SharePoint 2013 中建立查詢 (https://msdn.microsoft.com/library/jj163973.aspx)>。For more information, see Building search queries in SharePoint 2013 (https://msdn.microsoft.com/library/jj163973.aspx).

另請參閱See also

SharePoint Server 中的查詢變數Query variables in SharePoint Server

SharePoint Server 中的預設連接器Default connectors in SharePoint Server

在結果來源中轉換查詢Transforming queries in result sources

關於結果來源與同盟About result sources and federation