在 SharePoint Server 中建立 web 內容管理查詢的規則Create query rules for web content management in SharePoint Server

摘要:了解如何建立和管理查詢規則以改善搜尋結果。Summary: Learn how to improve search results by creating and managing query rules.

不使用任何的自訂程式碼、 Search service 應用程式管理員、 網站集合管理員及網站擁有者可協助建立查詢規則以回應使用者的用途的搜尋。在 [查詢規則,指定條件和相互關聯的動作。查詢符合的查詢規則條件,搜尋系統會執行以改善搜尋結果的相關性,例如縮小結果或變更結果的顯示的順序的規則中指定的動作。例如,查詢規則條件可能是中查詢字詞符合特定字詞的 SharePoint Server 字詞組,或該查詢會經常執行特定結果來源上影片的搜尋系統中。查詢規則條件滿足、 時的相互關聯的動作可能是顯示在搜尋結果頂端的特定項目。假設您有其中所有公司事件會都維持在文件庫中,如以目錄共用與您想要升級的第一個輔助工具研討會內部網路網站。為達成此目的,您會建立查詢規則,提升第一個輔助工具研討會頂端的搜尋結果時某人搜尋"研討會 」 或 「 事件 」。Without using any custom code, Search service application administrators, site collection administrators, and site owners can help searches respond to the intent of users by creating query rules. In a query rule, you specify conditions and correlated actions. When a query meets the conditions in a query rule, the search system performs the actions specified in the rule to improve the relevance of the search results, such as by narrowing results or changing the order in which results are displayed. For example, a query rule condition could be that a term in a query matches a particular term in a SharePoint Server term set, or that a query is frequently performed on a particular result source in a search system, such as videos. When the query rule condition is satisfied, a correlated action could be to show a specific item at the top of the search results. Say you have an intranet site where all company events are maintained in a library that you have shared as a catalog, and you want to promote a first-aid seminar. To do this, you create a query rule that boosts the first-aid seminar to the top of the search results when someone searches for "seminar" or "event."

您可以針對一或多個結果來源設定查詢規則,還可以指定查詢規則發生作用的時段。You can configure query rules for one or more result sources, and you can specify the time period during which the query rule is active.

如需查詢規則的詳細資訊,請參閱 <規劃結果來源和查詢規則規劃 SharePoint Server 2016 跨網站發佈網站的搜尋For more information about query rules, see Plan result sources and query rules in Plan search for cross-site publishing sites in SharePoint Server 2016.

開始之前Before you begin

注意

因為在網際網路資訊服務 (IIS) 網站執行 SharePoint Server、 系統管理員和使用者而定的瀏覽器提供的協助工具功能。SharePoint Server 支援支援的瀏覽器的協助工具功能。如需詳細資訊,請參閱下列資源: >規劃瀏覽器支援> SharePoint 2013 的協助工具> SharePoint 2013 產品的協助工具功能> 快速鍵> 觸控Because SharePoint Server runs as websites in Internet Information Services (IIS), administrators and users depend on the accessibility features that browsers provide. SharePoint Server supports the accessibility features of supported browsers. For more information, see the following resources: > Plan browser support> Accessibility for SharePoint 2013> Accessibility features in SharePoint 2013 Products> Keyboard shortcuts> Touch

建議您先設定網站、整合目錄,並設定目錄頁面及目錄項目頁面,再開始建立查詢規則。如此一來,您就可以較輕易地測試及確認不同查詢規則如何套用至網站上的不同搜尋網頁組件。We recommend that you set up your site, integrate a catalog, and set up your category pages and catalog item pages before you begin to create query rules. This is because you can then more easily test and verify how the different query rules apply to the different Search Web Parts you have on your site.

在 SharePoint Server 伺服器陣列的不同層級建立查詢規則Creating query rules at different levels in a SharePoint Server farm

您可以建立 Search Service 應用程式、網站集合或網站的查詢規則。下表顯示每個案例中建立查詢規則所需的權限,以及可在何處使用查詢規則。You can create a query rule for a Search service application, a site collection, or a site. The following table shows the permissions that are required to create a query rule in each case, and where the query rule can be used.

查詢規則的層級和權限Levels and permissions for query rules

在此層級建立查詢規則When you create a query rule at this level 您必須具備此權限You must have this permission 可使用查詢規則的地方The query rule can be used in
Search Service 應用程式Search service application
Search Service 應用程式管理員Search service application administrator
Web 應用程式中使用 Search Service 應用程式的所有網站集合All site collections in web applications that consume the Search service application
網站集合Site collection
網站集合管理員Site collection administrator
網站集合中的所有網站All sites in the site collection
網站Site
網站擁有人Site owner
該網站The site

若要新增或編輯的查詢規則,您必須前往管理查詢規則」 頁面。根據您要在其中建立查詢規則的層級,使用下列其中一個程序移至 [管理查詢規則] 頁面上。To add or edit a query rule, you must go to the Manage query rules page. Depending on the level at which you are creating the query rule, use one of the following procedures to go to the Manage query rules page.

移至 Search Service 應用程式的管理查詢規則頁面To go to the Manage query rules page for a Search service application

  1. 確認執行此程序的使用者帳戶為否為 Search Service 應用程式管理員。Verify that the user account that performs this procedure is an administrator for the Search service application.

  2. 在管理中心中,按一下 [應用程式管理] 區段的 [管理服務應用程式]。In Central Administration, in the Application Management section, click Manage service applications.

  3. 按一下您要新增查詢規則的 Search Service 應用程式。Click the Search service application to which you want to add query rules.

  4. 在 [搜尋管理] 頁面上的 [快速啟動] 中 [查詢與結果] 區段中的搜尋服務應用程式上按一下 [查詢規則]。On the Search Administration page for the Search service application, in the Quick Launch, in the Queries and Results section, click Query Rules.

    移至發佈網站集合的管理查詢規則頁面To go to the Manage query rules page for a publishing site collection

  5. 確認執行此程序的使用者帳戶為發佈網站集合的網站集合管理員。Verify that the user account that performs this procedure is a site collection administrator for the publishing site collection.

  6. 發佈的網站集合,在 [設定] 功能表上按一下 [網站設定]。On the publishing site collection, on the Settings menu, click Site Settings.

  7. 按一下 [網站設定] 頁面上的 [網站集合管理] 區段中的 [搜尋查詢規則]。On the Site Settings page, in the Site Collection Administration section, click Search Query Rules.

    移至網站的管理查詢規則頁面To go to the Manage query rules page for a site

  8. 請確認執行此程序的使用者帳戶為網站擁有人群組的成員。Verify that the user account that performs this procedure is a member of the Owners group for the site.

  9. 在 [網站設定] 功能表上按一下 [網站設定]。On the Settings menu for the site, click Site Settings.

  10. 按一下 [網站設定] 頁面上的 [網站管理] 區段中的 [查詢規則]。On the Site Settings page, in the Site Administration section, click Query Rules.

建立查詢規則Create a query rule

若要建立查詢規則To create a query rule

  1. 在 [管理查詢規則] 頁面中選取結果來源] 功能表中選取新查詢規則的結果來源。On the Manage Query Rules page, in the Select a Result Source menu, select a result source for the new query rule.

  2. 按一下 [新增查詢規則Click New Query Rule.

  3. 在 [新增查詢規則] 頁面的 [一般資訊] 區段的 [規則名稱] 欄位中輸入查詢規則的名稱。On the Add Query Rule page, in the General Information section, in the Rule name field, type the name for the query rule.

  4. 按一下以展開 [內容] 區段。Click to expand the Context section.

  5. 在 [內容] 區段中,選取下列其中一項:In the Context section, select one of the following:

    • 若要將查詢規則套用至所有的結果來源,請選取 [所有來源]。To apply the query rule to all result sources, select All sources.

    • 若要將查詢規則套用至一或多個特定結果來源,請選取 [這些來源之一。根據預設,會選取您在步驟 1 中指定的結果來源。若要新增查詢規則的結果來源,請執行下列動作:To apply the query rule to one or more specific result sources, select One of these sources. By default, the result source that you specified in step 1 is selected. To add a result source for the query rule, do the following:

      按一下 [新增來源]。在 [新增來源] 對話方塊中選取結果來源] 和 [儲存Click Add Source. In the Add Source dialog box, select a result source, and then click Save.

  6. 若要限制查詢規則類別 — 例如應該引發只有當從受管理的導覽字詞的字詞集查詢規則會包含在查詢 — 按一下 [顯示更多條件],然後指定下列:To restrict the query rule to categories —for example, that a query rule should fire only when a term from your managed navigation term set is included in the query — click Show more conditions, and then specify the following:

    • 若要限制查詢規則的類別,按一下 [新增類別]。在 [從分類匯入] 對話方塊中,選取 [字詞庫的查詢中您包含的時間會觸發、 查詢規則] 和 [儲存To restrict the query rule to a category, click Add category. In the Import from Taxonomy dialog box, select a term that when you include it in a query will cause the query rule to fire, and then click Save.

    • 若要將查詢規則限制於使用者區段,請執行下列操作:To restrict the query rule to a user segment, do the following:

  7. 按一下 [新增使用者區段]Click Add User Segment.

  8. 在 [新增使用者區段] 對話方塊的 [標題] 欄位中輸入此規則的標題。In the Add User Segment dialog box, in the Title field, type the title for this rule.

  9. 在 [從分類匯入] 對話方塊中,選取代表使用者區段,會使其出現在查詢時會觸發查詢規則的字詞。In the Import from taxonomy dialog box, select a term that represents a user segment that will cause the query rule to fire when it appears in a query.

  10. 按一下 [儲存]Click Save

  11. 在 [查詢條件] 區段中選取其中一個條件列於下表中。In the Query Conditions section, select one of the conditions listed in the following table.

    注意

    當您建立查詢規則的已使用搜尋技術 (本文說明為搜尋網頁組件)、 網頁組件的目錄頁面與您想設定作為查詢條件網頁組件中的查詢時,按一下 [移除條件] 和然後跳到步驟 8。您應該也這麼做如果您想要引發查詢規則,每當使用者輸入不要在搜尋方塊中。When you create query rules for catalog pages that have Web Parts that use search technology (described in this article as Search Web Parts), and you want the query that is configured in the Web Parts to act as the query condition, click Remove Condition, and then go to step 8. You should also do this if you want a query rule to fire every time that a user types anything in a search box.

查詢條件Query condition 描述Description 設定Configuration 範例Example
查詢完全符合關鍵字Query Matches Keyword Exactly
若您希望當查詢完全符合您指定的字詞或片語時觸發查詢規則,請選取此選項。Select this option if you want the query rule to fire when a query exactly matches a word or phrase that you specify.
在 [查詢完全符合這些片語之一] 文字方塊中輸入以分號分隔的一或多個片語。In the Query exactly matches one of these phrases text box, type one or more phrases separated by semicolons.
您輸入"圖片;pic"查詢包含這些片語之一] 方塊中。使用者在搜尋方塊中輸入 「 圖片 」 或 「 pic"時就會引發查詢規則。規則不觸發使用者輸入"圖片"晴朗 picture"。You type "picture; pic" in the Query contains one of these phrases box. The query rule will fire when a user types "picture" or "pic" in a search box. The rule will not fire if a user types "pictures" or "sunny picture."
查詢包含動作字詞Query Contains Action Term
若您希望當查詢包含指出使用者要進行之動作的字詞時,會觸發查詢規則,請選取此選項。字詞必須位於查詢的開頭或結尾。Select this option if you want the query rule to fire when a query contains a term that indicates something that the user wants to do. The term must be at the beginning or end of the query.
執行下列其中一項操作,指定會觸發查詢規則的動作字詞:Specify the action term that will cause the query rule to fire by doing one of the following:
選取 [動作字詞是這些片語之一],然後輸入一或多個片語。Select Action term is one of these phrases, and type one or more phrases.
選取 [動作字詞是此字典中的項目,然後再按一下 [從分類匯入]。在 [從分類匯入] 對話方塊中選取的字詞組之字詞的] 和 [儲存Select Action term is an entry in this dictionary, and then click Import from taxonomy. In the Import from taxonomy dialog box, select a term from a term set, and then click Save.
您輸入的字詞 」 下載 「 在動作字詞是這些片語之一] 文字方塊中。當使用者輸入"下載 Contoso 電子資料工作表"的搜尋方塊中時,使用者可能不會搜尋文件包含 「 下載 」、 「 Contoso,"單字"電子,"和"資料工作表"。而使用者試圖下載 Contoso 電子資料工作表。當使用者輸入"下載 Contoso 電子資料工作表"的搜尋方塊、 查詢規則會觸發,並僅單字"Contoso","電子,"和"資料工作表"會傳遞至搜尋索引。You type the word "download" in the Action term is one of these phrases text box. When a user types "download Contoso Electronics datasheet" in a search box, the user is probably not searching for a document that contains the words "download," "Contoso," "Electronics," and "datasheet." Instead, the user is probably trying to download a Contoso Electronics datasheet. When a user types "download Contoso Electronics datasheet" in a search box, the query rule fires, and only the words "Contoso," "Electronics," and "datasheet" are passed to the search index.
查詢完全符合字典Query Matches Dictionary Exactly
若您希望當查詢完全符合字典項目時觸發查詢規則,請選取此選項。Select this option if you want the query rule to fire when the query exactly matches a dictionary entry.
從 * * 查詢包含此字典中的項目 * ] 功能表中選取字典。若要指定不同的字典,按一下 [從分類匯入],然後從 [從分類匯入] 對話方塊中,選取 [組之字詞的字詞,然後按一下 [儲存From the ** Query contains an entry in this dictionary ** menu, select a dictionary. To specify a different dictionary, click **Import from taxonomy, and then from the **Import from taxonomy* dialog box, select a term from a term set, and then click Save.
在網際網路商業案例中,您有名為 Brands 的字詞組,其中包含您目錄中的所有品牌名稱。當使用者輸入的名稱符合 Brands 字詞組中的字詞時,就會觸發查詢規則。In an Internet business scenario, you have a term set named Brands that contains all brand names within your catalog. The query rule will fire when a user types a name that matches a term from the Brands term set.
經常在來源查詢Query More Common in Source
若要在使用者於您指定的其他結果來源經常發出查詢時引發查詢規則,請選取此選項。Select this option if you want the query rule to fire if the query was frequently issued by users on a different result source that you specify.
在 [查詢是很可能用於此來源] 功能表中選取結果來源。In the Query is more likely to be used in this source menu, select a result source.
在 [查詢是很可能用於此來源] 功能表中選取本機視訊結果。如果使用者在搜尋方塊中輸入 「 訓練 》 及經常 word 型別卻在垂直影片的搜尋方塊中就會引發查詢規則。In the Query is more likely to be used in this source menu, you select Local Video Results. The query rule will fire if a user types the word "training" in a search box and that word was frequently typed in a search box in the Videos vertical.
常點選的結果類型Result Type Commonly Clicked
若您希望當其他使用者在輸入相同查詢後,經常點選特定結果類型時觸發查詢規則,請選取此選項。Select this option if you want the query rule to fire if other users frequently clicked a particular result type after they typed the same query.
在 [常點選的結果比對結果類型] 功能表中選取結果類型。In the Commonly clicked results match result type menu, select a result type.
在網際網路商業案例中,您有電子產品的目錄。每個產品皆有 PDF 資料工作表。因此當使用者查詢特定產品時,搜尋結果會傳回兩種結果類型:具有產品詳細資料頁面的連結,以及 PDF 資料工作表的連結。您可以建立當系統可日漸辨識出使用者經常點選 PDF 資料工作表的搜尋結果時,會觸發的查詢規則。若您知道使用者要搜尋的內容類型,您可以指定此查詢規則的動作。In an Internet business scenario, you have a catalog of electronic products. Each product has a PDF datasheet. So when users query for a specific product, the search results will return two result types: one that links to the page that has the product details, and one that links to the PDF datasheet. You can create a query rule that will fire if the system over time recognizes that users frequently click the search result for the PDF datasheet. When you know the type of content the user is looking for, you can specify an action for this query rule.
進階查詢文字比對Advanced Query Text Match
若您希望使用會觸發查詢規則的規則運算式、片語或字典項目,請選取此選項。Select this option if you want to use a regular expression, a phrase, or a dictionary entry that will cause the query rule to fire.
要比對某特定格式中的所有電話號碼,查詢比對此規則運算式] 方塊中指定規則運算式。To match all phone numbers that are in a certain format, you specify a regular expression in the Query matches this regular expression box.
若要比對格式為 nnn-nnn-nnnn 的所有電話號碼,您可以指定規則運算式為 "(?(\d{3}))?-?(\d{3})-(\d{4})"。To match all phone numbers that are in the format nnn-nnn-nnnn, you specify the regular expression "(?(\d{3}))?-?(\d{3})-(\d{4})".
To add conditions, click **Add Alternate Conditions**. 

> [!NOTE]
> The rule will fire when any condition is true. 
  1. 在 [動作] 區段中指定查詢規則觸發時要採取的動作。指定下列其中一項:In the Actions section, specify the action to take when the query rule fires. Specify one of the following:

    • 若要將個別結果升級使其顯示搜尋結果的最上方,按一下 [新增升級的結果(SharePoint 2010 產品的這呼叫首選)。在 [新增升級的結果] 對話方塊的 [標題] 欄位中輸入您想要授與此升級的結果的名稱。在 [ URL ] 欄位中輸入 URL 應該要升級的結果。轉譯做為橫幅而不是為超連結的 URL。按一下 [儲存]。To promote individual results so that they appear towards the top of search results, click Add Promoted Result (in SharePoint 2010 Products this was called Best Bets). In the Add Promoted Result dialog box, in the Title field, type the name that you want to give this promoted result. In the URL field, type the URL of the result that should be promoted. Render the URL as a banner instead of as a hyperlink. Click Save.

      您可以個別新增數個升級的結果。當有多個升級的結果時,您可以指定相對的排名。You can add several individual promoted results. When there is more than one promoted result, you can specify the relative ranking.

    • 若要提升搜尋結果的群組,按一下 [新增結果區塊]。如需詳細資訊,請參閱本文稍後 <建立及顯示結果區塊To promote a group of search results, click Add Result Block. For more information, see Create and display a result block later in this article.

    • 若要變更排名的搜尋結果,請按一下 [變更排名後的以變更查詢的結果。如需詳細資訊,請參閱本文稍後的變更排名的搜尋結果To change ranked search results, click Change ranked results by changing the query. For more information, see Change ranked search results later in this article.

  2. 若要使得查詢規則作特定時段,按一下 [發佈],然後指定時段。To make the query rule active during a particular time period, click Publishing, and then specify the period.

建立及顯示結果區塊Create and display a result block

結果區塊是數個以群組顯示的搜尋結果。以相同的方式為可以升級特定的結果,您可以將升級結果區塊時指定的查詢條件套用。例如,您可以建立名為黃色的項目有色彩的所有目錄項目結果區塊黃色。在網際網路商務案例其中有的電子產品型錄和您想要升級黃色 mp3 播放器,您可以建立的標示字詞mp3 播放器,與此動作是要將結果顯示的其中的所有項目就會引發查詢規則封鎖黃色的項目A result block is several search results that are displayed as a group. In the same manner as you can promote a specific result, you can promote a result block when a specified query condition applies. For example, you can create a result block named Yellow items for all catalog items that have the color yellow. In an Internet business scenario where you have a catalog of electronic products and you want to promote yellow mp3 players, you can create a query rule that fires for all items that are tagged with the term mp3 players , where the action is to display the result block Yellow items .

結果區塊會自動顯示在搜尋結果網頁組件中。若要從內容搜尋網頁組件中的結果區塊顯示結果,您必須加以設定,才能顯示結果區塊。Result blocks are automatically displayed in the Search Results Web Part. To display results from a result block in a Content Search Web Part, you have to configure it to display the result block.

當您設定的結果區塊的查詢條件時,您可以使用查詢變數。查詢變數是您不知道時指定的查詢值的預留位置。不過,執行查詢時,此資訊已知及可用時系統會將查詢傳送至索引。以下範例列出 {User.Name},這代表的顯示名稱的輸入查詢或 {searchBoxQuery} 的使用者,其代表使用者輸入的搜尋方塊中的查詢。當您使用查詢產生器設定查詢時,會顯示查詢變數的清單。(請參閱下列程序中的步驟 3)。When you configure the query condition for a result block, you can use query variables. Query variables are placeholders for values that you don't know when you specify the query. However, when the query is run, this information is known and can be used when the system sends the query to the index. Examples are {User.Name}, which represents the display name of the user who typed the query, or {searchBoxQuery}, which represents the query that a user typed in a search box. When you use Query Builder to configure the query, a list of query variables is shown. (See step 3 in the following procedure.)

若要建立結果區塊To create a result block

  1. 步驟 8 中的上一個程序,在 [新增查詢規則] 頁面上的 [動作] 區段中按一下 [新增結果區塊]。In step 8 of the previous procedure, on the Add Query Rule page, in the Actions section, click Add Result Block.

  2. 在 [區塊標題] 區段的 [標題] 欄位輸入結果區塊的名稱。In the Block Title section, in the Title field, type a name for the result block.

  3. 在 [查詢] 區段中,以指定的查詢,按一下 [啟動查詢建立器]。在 [查詢產生器] 中指定下列項目:In the Query section, to specify the query, click Launch Query Builder. In Query Builder, specify the following:

    • [基本] 索引標籤上選取 [從下列清單定義結果區塊的查詢的選項:On the BASIC tab, select options from the following lists to define the query for the result block:
選取查詢Select a query
選取結果來源,以指定要搜尋哪些內容。Select a result source to specify which content should be searched.
關鍵字篩選Keyword filter
您可以使用關鍵字篩選新增至查詢的查詢變數。請參閱SharePoint Server 中的查詢變數可用查詢變數的清單。You can use keyword filters to add query variables to your query. See Query variables in SharePoint Server for a list of available query variables.
您可以從下拉式清單中選取預先定義的查詢變數並再按一下 [新增關鍵字篩選將其新增至查詢。You can select pre-defined query variables from the drop-down list, and then add them to the query by clicking Add keyword filter.
屬性篩選Property filter
您可使用屬性篩選,以查詢搜尋結構描述中設為可查詢之 Managed 屬性的內容。You can use property filters to query the content of managed properties that are set to queryable in the search schema.
您可以從 [屬性篩選] 下拉式清單中選取的 managed 的屬性。按一下 [新增屬性篩選新增至查詢的篩選。You can select managed properties from the Property filter drop-down list. Click Add property filter to add the filter to the query.
  • 在 [排序] 索引標籤中,您可以指定排序結果區塊中的搜尋結果的方式。在排序方式] 下拉式清單中:On the SORTING tab, you can specify how search results within your result block should be sorted. In the Sort by drop-down list:

  • 用來排序設定為可排序搜尋結構描述中的 managed 屬性,從清單中選取一個 managed 的屬性,然後選取遞減排序] 或 [遞增。若要新增更多排序層級,請按一下 [新增排序層級To sort by managed properties that are set as sortable in the search schema, select a managed property from the list, and then select Descending or Ascending. To add more sorting levels, click Add sort level.

    注意

    [!附註] 搜尋結果的排序區分大小寫。Sorting of search results is case sensitive.

  • 若要按相關排名排序,選取 [排名],並再執行下列動作:To sort by relevance rank, select Rank, and then do the following:

  • 在 [排名模型] 清單中選取 [排名模型来用來排序搜尋結果 (此為選用選項)。In the Ranking Model list, select which ranking model to use for sorting search results (this selection is optional).

  • 動態排序] 區段來指定其他排名新增特定條件套用、 按一下 [新增動態排序規則,以及然後指定設定格式化條件規則時要變更搜尋結果順序的規則。In the Dynamic ordering section, to specify additional ranking by adding rules that will change the order of search results when certain conditions apply, click Add dynamic ordering rule, and then specify conditional rules.

  • 在 [測試] 索引標籤上您可以預覽傳送的查詢。On the TEST tab, you can preview the query that is sent.

查詢文字Query text
可顯示內容搜尋網頁組件所執行的最終查詢。查詢文字會以將動態變數取代為目前值之原始查詢範本為依據,因此其他查詢變更就可能必須以查詢規則形式來進行。Shows the final query that will be run by the Content Search Web Part. It is based on the original query template where dynamic variables are substituted with current values. Other changes to the query may have to be made as part of query rules.
Click **Show more** to display additional information. 
查詢範本Query template
顯示套用至查詢的查詢範本內容。Shows the content of the query template that is applied to the query.
查詢範本變數Query template variables
顯示將套用至查詢伺服器及套用至目前的頁面變數的值的查詢變數。您可以輸入其他值來測試查詢會有作用。按一下 [測試查詢] 按鈕預覽搜尋結果。Shows the query variables that will be applied to the query, and the values of the variables that apply to the current page. You can type other values to test the effect they will have on the query. Click the Test Query button to preview the search results.
  1. 在 [查詢] 區段的 [設定查詢] 方塊中,在搜尋此來源] 下拉式清單中,選取應該要套用此結果區塊的結果來源。In the Query section, in the Configure Query box, in the Search this Source drop-down list, select the result source to which this result block should be applied.

  2. 在 [查詢] 區段中的項目] 下拉式清單中,選取結果區塊来顯示多少結果。In the Query section, in the Items drop-down list, select how many results to show in the result block.

  3. 按一下以展開 [設定] 區段。Click to expand the Settings section.

    結果區塊只會顯示您在上一個步驟中指定的搜尋結果數目。不過,您可以新增顯示更多連結將顯示結果區塊的所有搜尋結果的結果區塊的底部。若要新增更多顯示連結,請選取 [ 「 更多 」 連結會移至下列 URL,,然後輸入 URL。您可以使用查詢變數中此 URL — 例如http://www。<網站>/search/results.aspx?k={subjectTerms}The result block will only display the number of search results that you specified in the previous step. However, you can add a SHOW MORE link at the bottom of the result block that will show all search results for the result block. To add a SHOW MORE link, select "More" link goes to the following URL, and then type a URL. You can use query variables in this URL — for example, http://www.<site>/search/results.aspx?k={subjectTerms} .

  4. 在 [路由] 區段下的路由傳送至內容搜尋網頁組件的標籤、 [] 欄位中輸入路由傳送至內容搜尋網頁組件中,結果區塊的標籤或選取現有的標籤。下列程序中將使用此標籤。In the Routing section, in the field under Label for routing to a Content Search Web Part, type a label for routing the result block to a Content Search Web Part, or select an existing label. You will use this label in the following procedure.

  5. 按一下 [ OK ]。Click OK.

    若要設定內容搜尋網頁組件以顯示結果區塊To configure a Content Search Web Part to display a result block

  6. 新增內容搜尋網頁組件至頁面Configure Search Web Parts in SharePoint Server中的 「 新增內容搜尋網頁組件至頁面 」 所述。Add a Content Search Web Part to a page as described in "Add a Content Search Web Part to a page" in Configure Search Web Parts in SharePoint Server.

  7. 網頁組件中按一下內容搜尋網頁組件功能表]箭頭,然後再按一下 [編輯網頁組件In the Web Part, click the Content Search Web Part Menu arrow, and then click Edit Web Part.

  8. 在網頁組件] 工具窗格的 [屬性] 區段中依序展開 [設定] 區段。In the Web Part tool pane, in the Properties section, expand the Settings section.

  9. 在 [設定] 區段中,從結果表格] 清單中,選取您想要顯示的結果區塊的標籤。標籤是您在先前的程序中,若要建立結果區塊中的步驟 7 中所指定的項目。In the Settings section, from the Result Table list, select the label of the result block that you want to display. The label is what you specified in step 7 in the previous procedure, To create a result block.

  10. 若要使用查詢結果所傳回之來自另一個網頁組件] 頁面上輸入時顯示結果區塊中,從所提供的查詢結果清單中選取網頁組件。To use the query results that are returned from another Web Part on the page as input when displaying the result block, from the Query results provided by list, select a Web Part.

注意

在內容搜尋網頁組件中顯示結果區塊時,無法透過 [控制項顯示範本] 支援搜尋結果的分頁。When displaying a result block in a Content Search Web Part, paging of search results is not supported through the Control Display Template.

在內容搜尋網頁組件中顯示升級的結果Display promoted results in a Content Search Web Part

顯示升級的內容搜尋網頁組件中的結果To display promoted results in a Content Search Web Part

  1. 新增內容搜尋網頁組件至頁面Configure Search Web Parts in SharePoint Server中的 「 新增內容搜尋網頁組件至頁面 」 所述。Add a Content Search Web Part to a page as described in "Add a Content Search Web Part to a page" in Configure Search Web Parts in SharePoint Server.

  2. 網頁組件中按一下內容搜尋網頁組件功能表]箭頭,然後再按一下 [編輯網頁組件In the Web Part, click the Content Search Web Part Menu arrow, and then click Edit Web Part.

  3. 在網頁組件] 工具窗格的 [屬性] 區段中依序展開 [設定] 區段。In the Web Part tool pane, in the Properties section, expand the Settings section.

  4. 在 [設定] 區段的 [結果表格] 清單中選取 [ specialtermresults]In the Settings section, in the Result Table list, select SpecialTermResults.

變更排名的搜尋結果Change ranked search results

排名模型會計算搜尋結果的排名順序。您可以升級或降級搜尋結果中的項目,以變更此排名。例如,針對包含 "download toolbox" 的查詢,可以建立能夠辨識字詞 "download" 為動作字詞的查詢規則,並變更排名的搜尋結果,以升級您內部網路中特定下載網站的 URL。您也可以根據一些變數,例如副檔名或特定關鍵字,動態變更搜尋結果排序。以變更查詢的方式變更排名的搜尋結果之優點為,結果是經過安全性調整且可精簡。此外,若不再提供文件時,甚至不會顯示搜尋結果。The ranking model calculates a ranking order of search results. You can change this ranking by promoting or demoting items within the search results. For example, for a query that contains "download toolbox," you can create a query rule that recognizes the word "download" as an action term, and change the ranked search results to promote a URL of a particular download site on your intranet. You can also change the sorting order of the search results dynamically, based on several variables such as file name extension or specific keywords. Changing ranked search results by changing the query has the advantage that the results are security trimmed and refinable. Moreover, the search results will not appear if the document is no longer available.

透過變更查詢來變更排名的搜尋結果To change ranked search results by changing the query

  1. 步驟 8 中的程序建立查詢規則,在 [新增查詢規則] 頁面上的 [動作] 區段中按一下 [變更排名後的以變更查詢的結果From step 8 of the procedure Create a query rule, on the Add Query Rule page, in the Actions section, click Change ranked results by changing the query.

  2. 在 [建立您的查詢] 對話方塊中,指定下列項目:In the Build Your Query dialog box, specify the following:

    • 在 [基本] 索引標籤上選取選項清單中的下列變更排名的搜尋結果:On the BASIC tab, select options from the following lists to change ranked search results:
選取查詢Select a query
選取結果來源,以指定要搜尋哪些內容。Select a result source to specify which content should be searched.
關鍵字篩選Keyword filter
您可以使用關鍵字篩選新增至查詢的查詢變數。請參閱SharePoint Server 中的查詢變數可用查詢變數的清單。You can use keyword filters to add query variables to your query. See Query variables in SharePoint Server for a list of available query variables.
您可以從下拉式清單中選取預先定義的查詢變數並再按一下 [新增關鍵字篩選將其新增至查詢。You can select pre-defined query variables from the drop-down list, and then add them to the query by clicking Add keyword filter.
屬性篩選Property filter
您可使用屬性篩選,以查詢搜尋結構描述中設為可查詢之 Managed 屬性的內容。You can use property filters to query the content of managed properties that are set to queryable in the search schema.
您可以從 [屬性篩選] 下拉式清單中選取的 managed 的屬性。按一下 [新增屬性篩選新增至查詢的篩選。You can select managed properties from the Property filter drop-down list. Click Add property filter to add the filter to the query.
  • 在 [排序] 索引標籤中,您可以指定如何搜尋結果的排序方式執行下列動作:On the SORTING tab, you can specify how search results should be sorted by doing the following:

  • 排序方式] 下拉式清單中:In the Sort by drop-down list:

  • 用來排序設定為可排序搜尋結構描述中的 managed 屬性,從清單中選取一個 managed 的屬性,然後選取遞減排序] 或 [遞增。若要新增更多排序層級,請按一下 [新增排序層級To sort by managed properties that are set as sortable in the search schema, select a managed property from the list, and then select Descending or Ascending. To add more sorting levels, click Add sort level.

    注意

    [!附註] 搜尋結果的排序區分大小寫。Sorting of search results is case sensitive.

  • 若要按相關排名排序,選取 [排名],並再執行下列動作:To sort by relevance rank, select Rank, and then do the following:

  • 在 [排名模型] 清單中選取 [排名模型来用來排序搜尋結果 (此為選用選項)。In the Ranking Model list, select which ranking model to use for sorting search results (this selection is optional).

  • 動態排序] 區段來指定其他排名新增特定條件套用、 按一下 [新增動態排序規則,以及然後指定設定格式化條件規則時要變更搜尋結果順序的規則。In the Dynamic ordering section, to specify additional ranking by adding rules that will change the order of search results when certain conditions apply, click Add dynamic ordering rule, and then specify conditional rules.

  • 在 [測試] 索引標籤中,您可預覽查詢。On the TEST tab, you can preview the query.

查詢文字Query text
可顯示內容搜尋網頁組件所執行的最終查詢。查詢文字會以將動態變數取代為目前值之原始查詢範本為依據,因此其他查詢變更就可能必須以查詢規則形式來進行。Shows the final query that will be run by the Content Search Web Part. It is based on the original query template where dynamic variables are substituted with current values. Other changes to the query may have to be made as part of query rules.
Click **Show more** to display additional information. 
查詢範本Query template
顯示套用至查詢的查詢範本內容。Shows the content of the query template that is applied to the query.
查詢範本變數Query template variables
顯示將套用至查詢伺服器及套用至目前的頁面變數的值的查詢變數。您可以輸入其他值來測試查詢會有作用。按一下 [測試查詢] 按鈕預覽搜尋結果。Shows the query variables that will be applied to the query, and the values of the variables that apply to the current page. You can type other values to test the effect they will have on the query. Click the Test Query button to preview the search results.

停用查詢規則Make a query rule inactive

取用 Search Service 應用程式之 Web 應用程式中的網站集合及網站會繼承在 Search Service 應用程式層級建立的查詢規則。同樣地,網站集合中的網站也會繼承在網站集合層級建立的查詢規則。若不要將繼承而來的查詢規則套用至網站,可針對網站將查詢規則設為停用。Query rules that are created at the Search service application level are inherited by site collections and sites that are in web applications that consume the Search service application. Similarly, query rules that are created at the site collection level are inherited by sites in the site collection. If you don't want a query rule to apply to a site that inherits it, you can set the query rule as inactive for the site.

停用網站的查詢規則To make a query rule inactive on a site

  1. 確認執行此程序的使用者帳戶是發佈網站上之擁有人群組的成員。Verify that the user account that performs this procedure is a member of the Owners group on the publishing site.

  2. 發佈的網站集合,在 [設定] 功能表上按一下 [網站設定]。On the publishing site collection, on the Settings menu, click Site Settings.

  3. 在網站集合中,在 [設定] 功能表中按一下 [網站設定]。In the site collection, in the Settings menu, click Site Settings.

  4. 按一下 [網站設定] 頁面上的 [搜尋] 區段中的 [查詢規則]。On the Site Settings page, in the Search section, click Query Rules.

  5. 在 [管理查詢規則] 頁面上的 [選取結果來源] 功能表上選取包含您想要停用之查詢規則的結果來源。On the Manage Query Rules page, on the Select a Result Source menu, select the result source that contains the query rule that you want to make inactive.

  6. 在 [名稱] 欄中指向您想要停用、 按一下出現箭號,然後按一下 [變為已停用查詢規則。In the Name column, point to the query rule that you want to make inactive, click the arrow that appears, and then click Make Inactive.

排名查詢規則Rank query rules

當啟用 Search Service 應用程式、網站集合或網站的多個查詢規則時,可以針對在該層級上執行的查詢觸發多個規則。根據預設,不會依照指定的順序觸發規則。您可以藉由將建立的查詢規則新增至查詢群組,以控制規則觸發的順序。若要執行此操作,請選取要新增至群組的規則,然後指定群組中的規則要觸發的順序。您也可以使群組中最低排名的查詢規則,即使受到觸發也不會被觸發。When multiple query rules are active for a Search service application, a site collection, or a site, more than one rule can fire for a query that is performed at that level. By default, the rules do not fire in a prescribed order. You can control the order in which the rules fire by adding the query rules that you create to query groups. To do this, you select rules to add to a group, and then you specify the order in which the rules in the group will fire if they are triggered. You can also prevent query rules that rank lowest in a group from firing even if they are triggered.

為網站集合排名查詢規則To rank query rules for a site collection

  1. 確認執行此程序的使用者帳戶為發佈網站集合的網站集合管理員。Verify that the user account that performs this procedure is a site collection administrator for the publishing site collection.

  2. 發佈的網站集合,在 [設定] 功能表上按一下 [網站設定]。On the publishing site collection, on the Settings menu, click Site Settings.

  3. 按一下 [網站設定] 頁面上的 [網站集合管理] 區段中的 [搜尋查詢規則]。On the Site Settings page, in the Site Collection Administration section, click Search Query Rules.

  4. 在 [管理查詢規則] 頁面上的 [選取結果來源] 功能表上選取包含要加入群組之查詢規則的結果來源。On the Manage Query Rules page, on the Select a Result Source menu, select the result source that contains the query rules that you want to group.

  5. 針對您所建立且要新增至群組的每個查詢規則,指向規則,並選取核取方塊。For each query rule that you created that you want to add to a group, point to the rule and select the check box.

    注意

    您為此網站集合所建立的查詢規則會列在 [已針對此網站集合定義] 區段中。Query rules that you created for this site collection are listed in the Defined for this site collection section.

  6. 按一下 [順序選取的規則]。Click Order Selected Rules.

  7. 在 [順序選取規則] 對話方塊中,執行下列任一動作,然後按一下 [確定]In the Order Selected Rules dialog box, do either of the following, and then click OK:

    • 選取 [移至具有此名稱的新群組的規則,然後輸入群組的名稱。Select Move rules to new group with this name, and then type a name for the group.

    • 選取 [將規則至現有的群組和下拉式清單中選取群組。Select Move rules to existing group and select a group in the drop-down list.

  8. 在 [管理查詢規則] 頁面上執行下列動作:On the Manage Query Rules page, do the following:

  9. 若要變更群組中規則的觸發順序,請變更規則的號碼順序。To change the order in which a rule in a group will fire if it is triggered, change the numeric order of the rule.

  10. 若要防止的方式進行排名最低引發,應該在繼續/停止] 下拉式清單中的 [動作] 欄中的最後引發的群組的查詢規則的列中的群組中的查詢規則選取 [停止]。To prevent query rules that are ranked lowest in the group from firing, in the row for the group's query rule that should fire last, in the Actions column, in the Continue/Stop drop-down list, select Stop.

另請參閱See also

概念Concepts

在 SharePoint Server 中規劃轉換查詢和順序結果Plan to transform queries and order results in SharePoint Server

Query variables in SharePoint ServerQuery variables in SharePoint Server