如何變更 SharePoint Server 中顯示哪些搜尋結果的順序How to change the order in which search results are displayed in SharePoint Server

摘要:了解如何變更 SharePoint Server 中顯示哪些搜尋結果的順序。Summary: Learn how to change the order in which search results are displayed in SharePoint Server.

如何變更 SharePoint Server 中的搜尋結果顯示的方式之數列中我們清楚如何自訂搜尋結果的顯示新增自訂圖示加入與屬性的方式。In the series How to change the way search results are displayed in SharePoint Server we explained how to customize the way search results are displayed by adding custom icons and properties.

也就是說,顯示搜尋結果、 設計和內容是確實非常重要。不過,會經常 trumps 兩者的一回事: 顯示哪些搜尋結果的順序。When it comes to displaying search results, design and content are indeed very important. However, there is one thing that often trumps them both: the order in which search results are displayed.

尋找在搜尋結果時設想您自己的行為。您按一下頻率檢視搜尋結果的第二頁回覆通常是"少"。Think of your own behavior when looking at search results. How often do you click to view the second page of search results? Often, the answer is "rarely."

如此時顯示的搜尋結果,務必使用者要尋找的結果會顯示為高向上儘可能在搜尋結果清單中。本文中,要如何變更 SharePoint Server 中的搜尋結果顯示的方式一系列 addendum 說明如何使用查詢規則來變更搜尋結果的顯示順序。為示範查詢規則的運作方式,我們會使用範例從內部的 Microsoft 搜尋中心。So, when displaying search results, it is important that the results that your users are looking for are displayed as high up in the search results list as possible. This article, an addendum to the How to change the way search results are displayed in SharePoint Server series, explains how to use a query rule to change the order in which search results are displayed. To demonstrate how query rules work, we'll use an example from an internal Microsoft Search Center.

在本文中,您將了解:In this article, you'll learn:

項目一次的問題?What was the problem again?

當您知道 Microsoft 會跨 TechNet、 MSDN 和 Office.com 發佈千分位的文章。若要協助發佈程序中,我們使用多個 SharePoint 清單。在清單中的每個項目代表文章或媒體檔案。若要可輕鬆尋找特定清單項目的相關資訊,我們會建立可以搜尋整個這些清單的搜尋中心。As you know, Microsoft publishes thousands of articles across TechNet, MSDN, and Office.com. To help in the publishing process, we use several SharePoint lists. Each item in a list represents an article or a media file. To make it easy to find information about a particular list item, we created a Search Center that searches across these lists.

下列螢幕擷取畫面顯示哪些搜尋結果所顯示我們搜尋中心預設順序。請注意文章和圖像的搜尋結果所顯示混合式的順序。The following screen shot shows the default order in which search results were displayed in our Search Center. Notice that search results for articles and images were displayed in a mixed order.

搜尋結果預設順序

當使用者搜尋此搜尋中心內的某個項目時,他們通常會尋找文章的相關資訊。因此,以方便使用者尋找文章的資訊,我們想要變更搜尋結果的順序使圖像會顯示在底端。若要這樣做,我們需要建立查詢規則。When users search for something in this Search Center, they are usually looking for information about an article. So, to make it easier for users to find information about articles, we wanted to change the order of the search results so that images would be displayed at the bottom. To do this, we had to create a query rule.

當使用查詢規則: 定義指派之前When using query rules: define before you assign

查詢規則主要是顧名思義: 可套用至查詢的規則。但在開始將規則指派給您的查詢之前,您應該定義您想要執行的查詢規則。A query rule is largely what the name implies: a rule that can be applied to queries. But before you start to assign rules to your queries, you should define what you want the query rule to do.

基本上,您必須定義兩件事: 條件和動作。簡單來說,這而言向下定義下列:Basically, you have to define two things: a condition and an action. Simply put, this comes down to defining the following:

"何時 X (條件),請勿 Y (動作)"。"when X (condition), do Y (action)".

在搜尋中心案例中,我們知道動作組件:會代表圖像下方的搜尋結果清單中的顯示清單項目In our Search Center scenario, we knew the action part: Display list items that represent images at the bottom of the search results list .

在我們的清單,我們使用網站欄內容類型區分文章或媒體類型的清單項目代表的類型。例如,所有圖像都有"藝術 」內容類型的值。In our lists, we use the site column Content Type to differentiate between the type of articles or media types a list item represents. For example, all images have the value "Art" for Content Type .

美工圖案內容類型

根據此,我們可以使我最終定義已定義的條件組件:Based on this, we were able to define the condition part so that my final definition was:

內容類型 」 藝術 」 的清單項目時,顯示這些結尾處的搜尋結果清單中。When list items are of Content Type "Art", display these at the end of the search results list.

讓與備妥定義,我們可以開始建立進行這項工作之查詢規則。So, with the definition in place, we could begin to create the query rule that would make this happen.

如何建立查詢規則會變更顯示哪些搜尋結果的順序How to create a query rule that will change the order in which search results are displayed

根據您的權限層級,您可以在三層級建立查詢規則:Depending on your permission level, you can create a query rule on three levels:

權限等級Permission level 要套用查詢規則Where the query rule will be applied
Search Service 應用程式管理員Search service application administrator
伺服器陣列內的所有網站集合To all site collections within the farm
網站集合管理員Site collection administrator
對網站集合內的所有網站To all sites inside a site collection
網站集合擁有者Site collection owner
在單一站台To a single site

若要儲存空間,我們將只顯示您如何建立查詢規則為網站集合管理員。To save space, we'll only show you how to create a query rule as a Site collection administrator.

  1. 移至 [網站設定 --> 搜尋查詢規則Go to Site Settings --> Search Query Rules.

    搜尋查詢規則

  2. 在 [管理查詢規則] 頁面上,從 [選取結果來源] 功能表選取應該要套用查詢規則的結果來源。On the Manage Query Rules page, from the Select a Result Source menu, select the result source to which the query rule should be applied.

    選取結果來源

  3. 選取 [新增查詢規則]。Select New Query Rule.

    新增查詢規則

  4. 在 [新增查詢規則] 頁面的 [規則名稱] 欄位中輸入查詢規則的名稱。On the Add Query Rule page, in the Rule name field, enter a name for the query rule.

    在搜尋中心案例中,我們名為查詢規則降級美工圖案In our Search Center scenario, we named the query rule Demote Art .

    查詢規則名稱

  5. 在 [查詢條件] 區段中,指定會觸發查詢規則的條件。In the Query Conditions section, specify the conditions that will trigger the query rule.

    在搜尋中心案例中,我們想要觸發使用者輸入查詢的每次查詢規則。換句話說,我們沒有要透過特定條件觸發查詢規則。因此,我們選取移除條件]。In our Search Center scenario, we wanted the query rule to be triggered every time that a user entered a query. In other words, we didn't want the query rule to be triggered by a specific condition. Therefore, we selected Remove Condition.

    移除條件

  6. 在 [動作] 區段中,指定您想要執行動作時觸發查詢規則。In the Actions section, specify what you want the query rule to do when it is triggered.

    在搜尋中心案例中,我們選取變更排名後的以變更查詢的結果。這會開啟其中我們定義我們想要執行的查詢規則] 對話方塊。In our Search Center scenario, we selected Change ranked results by changing the query. This opened a dialog box where we could define what we wanted the query rule to do.

    已變更排名的結果

  7. 我們想要變更搜尋結果的順序。因此,在 [建立您的查詢] 對話方塊中,選取 [排序] 索引標籤。We wanted to change the order of search result. Therefore, in the Build Your Query dialog box, we selected the SORTING tab.

    排序

    從 [排序方式] 功能表選取 [排名From the Sort by menu, we selected Rank.

    依排名排序

    動態排序] 區段中,選取 [新增動態排序規則From the Dynamic ordering section, we selected Add dynamic ordering rule.

    新增動態規則

    從 [變更排名的時機] 功能表選取 [手動條件From the Change ranking when menu, we selected Manual condition.

    手動條件

    請記住,我們想要顯示在搜尋結果清單結尾處的內容類型美工圖案的清單項目。如此,在手動條件] 欄位中,我們輸入ContentType:Art ,並選取到下的 [降階Remember, we wanted list items of Content Type Art to be displayed at the end of the search results list. So, in the Manual condition field, we entered ContentType:Art , and selected Demote to bottom.

    降級內容

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

    • ContentType是代表網站欄內容類型的 managed 的屬性。如何顯示搜尋結果-選項 1 in SharePoint Server 中的自訂受管理屬性的值會說明如何尋找 managed 的屬性名稱。ContentType is the managed property that represents the site column Content Type. How to display values from custom managed properties in search results - option 1 in SharePoint Server explains how to find managed property names.

    • 冒號: 表示"包含"。The colon : means "contains".

    • 美工圖案是 managed 的屬性值。Art is the managed property value.

    • 到下的 [降階為應該採取的動作。Demote to bottom is the action that should be taken.

      將它放在一起,且其符合我們指定的定義: "藝術 」 的內容類型的清單項目時顯示這些結尾處的搜尋結果清單中Put it together, and it matches the definition we specified: When list items are of Content Type "Art", display these at the end of the search results list .

  8. 選取[確定],然後儲存Select OK, and then Save.

新建立的查詢規則會列在 [管理查詢規則] 頁面。Your newly created query rule will be listed on the Manage Query Rules page.

在搜尋中心案例中,我們可以看到已建立降級藝術查詢規則。In our Search Center scenario, we could see that the Demote Art query rule was created.

已建立查詢規則

我們現在會在搜尋中心中輸入搜尋,我們可以看到文章所顯示的搜尋結果] 清單的頂端和底端所顯示的圖像。好 !When we now entered a search in the Search Center, we could see that articles were displayed at the top of the search results list, and images were displayed at the bottom. Nice!

之後結果

如何知道查詢規則的套用?How do I know that the query rule's been applied?

在搜尋中心案例中,我們可以輕鬆地確認我們建立的查詢規則已被套用。但是,如果您不確定是否套用查詢規則的相關,搜尋結果網頁組件可讓您解答。In our Search Center scenario, we could easily verify that the query rule we created was being applied. But, if you are uncertain about whether your query rule is being applied, the Search Results Web Part can give you an answer.

若要確認要套用查詢規則的步驟如下:Here are the steps to verify that a query rule is being applied:

  1. 在您搜尋結果] 頁面上,選取要編輯搜尋結果網頁組件On your search results page, select to edit the Search Results Web Part.

  2. 在 [網頁組件] 工具窗格中,選取 [變更查詢]。In the Web Part tool pane, select Change query.

  3. 在 [建立您的查詢] 對話方塊中,選取 [測試] 索引標籤] 和 [顯示更多In the Build Your Query dialog box, select the TEST tab, and then Show more.

    測試

  4. {Searchboxquery} ] 欄位中輸入查詢您知道應該會導致會觸發查詢規則,然後選取 [測試查詢]In the {searchboxquery} field enter a query that you know should cause the query rule to be triggered, and then select Test query.

    驗證查詢規則

在搜尋中心案例中,我們無法確認我們查詢規則已透過查看 [下列工作:In our Search Center scenario, we could verify that our query rule was working by looking at the following:

  1. 套用的查詢規則] 欄位中所顯示我們的查詢規則,降階美工圖案的名稱。In the field Applied query rules, the name of our query rule, Demote art, was shown.

  2. 在 [查詢文字方塊] 區段中 XRANK 已套用至ContentType:ArtIn the Query text section, XRANK was applied to ContentType:Art .

考量兩次再套用查詢規則Think two times before you apply a query rule

雖然這是相當簡單的查詢規則,我們看到效果是相當明顯。讓 word 的警告: 即使查詢規則會更好的變更顯示哪些搜尋結果的順序,您應考慮清楚再套用這些太多。效果可以是非常大且更複雜的查詢規則您有,每個查詢作業需要更多效能資源。Even though this was a fairly simple query rule, we saw that the effect was very noticeable. So a word of warning: even though query rules are great for changing the order in which search results are displayed, you should think carefully before you apply too many of them. The effects can be very large, and the more complex query rules that you have, the more performance resources each query will require.

但是,如果它們都使用小心,您可以建立搜尋中心很高興客戶的使用者。But, if they are used with caution, you can make the users of your Search Center very happy customers.