從網站欄到 Managed 屬性 - 發生了什麼事?From site column to managed property - What's up with that?

摘要: 了解網站欄如何「轉換」成 SharePoint Server 2016 中的 managed 屬性。Summary: Learn how site columns are "transformed" into managed properties in SharePoint Server 2016.

快速概觀Quick overview

階段 4: 設定搜尋並啟用在 SharePoint Server 中的目錄內容的編目中,我們示範了如何設定搜尋並啟用目錄內容的編目功能。在本文中,我們將說明網站欄在編目期間發生什麼狀況。In Stage 4: Set up search and enable the crawling of your catalog content in SharePoint Server we showed you how to set up search and enable crawling of your catalog content. In this article, we'll explain what happens to site columns during crawl.

進行目錄的編目時,目錄內容會新增至 搜尋索引 ,其中的網站欄會顯示成 編目Managed 屬性 。讓我們經由 搜尋索引 以及 編目Managed 屬性 ,進一步了解我們所要表達的意思。When a catalog is crawled, the catalog content is added to the search index, where the site columns are represented as crawled and managed properties. Let's take a closer look at what we mean by search index, and crawled and managed properties.

關於搜尋索引About the search index

首先,讓我們回到我們的概觀圖表。Let's start by going back to our overview diagram.

XSP 搜尋

  1. 進行內容來源的編目時,其內容和中繼資料會新增至搜尋索引。在我們的案例中,這表示 產品 目錄的內容會新增至搜尋索引。When a content source is crawled, its contents and metadata are added to the search index. In our scenario, that means the content from the Products catalog is added to the search index.

  2. 為了在發佈入口網站 (Contoso 網站) 上顯示內容,所以會使用搜尋網頁組件。搜尋網頁組件包含一項查詢,例如「[顯示所有紅色的 MP3 播放程式」(此查詢不是以這類通用語言進行,但現在,我們只想保持簡單)。所以當使用者瀏覽至包含搜尋網頁組件的頁面時,「紅色 MP3 播放程式」** 的查詢會自動傳送至搜尋索引。搜尋結果會從搜尋索引傳回,而所有紅色 MP3 播放程式都會顯示在頁面上的搜尋網頁組件中。To display content on the publishing portal (the Contoso website), Search Web Parts are used. Search Web Parts contain a query, for example, "show all MP3 players that have the color red" (the query is not made in such common language, but for now, let's just keep it simple). So when users browse to a page that contains a Search Web Part, the query for red MP3 players is automatically sent to the search index. The query result is returned from the search index, and all red MP3 players are shown in the Search Web Part on the page.

請務必了解:我們新增至搜尋索引的內容會決定從搜尋網頁組件發出查詢時,可以傳回哪些搜尋結果。簡言之,如果 產品 目錄的內容不會新增至搜尋索引,我們就無法在 Contoso 網站上顯示任何目錄內容。What is important to understand is that the content that we add to the search index determines which search results can be returned when queries are issued from Search Web Parts. Simply put, if the content from our Products catalog isn't added to the search index, we can't display any catalog content on the Contoso website.

關於編目和 Managed 屬性About crawled and managed properties

在編目期間,項目的內容和中繼資料都會以 編目屬性 表示。在我們的案例中,項目為儲存在 產品 目錄中的網站欄和值。您必須認識編目屬性的原因,在於我們稍後會使用編目屬性來設定精簡器。During a crawl, the contents and metadata of the items are represented as crawled properties. In our scenario, items are the site columns and the values that are stored in the Products catalog. The reason that you have to know about crawled properties, is because we'll later use crawled properties to configure refiners.

即使編目屬性包含值,但沒有搭檔也是「毫無用處」。這個搭檔就是 Managed 屬性。藉由建立編目屬性與 Managed 屬性 之間的對應,我們就能夠在 Contoso 網站上顯示內容。Even though crawled properties contain values, they are "useless" without a partner. This partner is a managed property. By creating a mapping between a crawled property and a managed property, we'll be able to display content on our Contoso website.

您必須認識 Managed 屬性的原因,在於我們稍後會在搜尋網頁組件中設定查詢時,以及定義如何在網頁上顯示搜尋結果時使用 Managed 屬性。The reason that you have to know about managed properties is because we'll later use managed properties when we configure queries in Search Web Parts, and when we define how search results should be displayed on a web page.

稍後將使用範例,更詳細地一併說明編目和 Managed 屬性的使用方式。現在,務必了解在 Contoso 網站上查詢和顯示內容時,我們將使用編目和 Managed 屬性,但 不會 使用 產品 目錄中的網站欄。The use of crawled and managed properties will be explained in more detail, together with examples, later. For now, it's important to understand that we'll use crawled and managed properties, and not the site columns from the Products catalog when querying for and displaying content on our Contoso website.

關於自動建立的編目和 Managed 屬性About automatically created crawled and managed properties

SharePoint 有多個對應至預設編目屬性的預設 Managed 屬性,例如「標題」。SharePoint has several default managed properties that are mapped to default crawled properties, for example, "Title".

在舊版的 SharePoint 中,在編目期間發現新項目時,使用者必須以手動方式建立新的 Managed 屬性,並將其對應至對應的編目屬性。In earlier versions of SharePoint, when a new item was discovered during a crawl, users would have to create a new managed property manually and map it to the corresponding crawled property.

在 SharePoint Server 2016 中,您可以使用 自動建立的編目和 Managed 屬性 。這可讓目錄擁有者的生活更輕鬆。In SharePoint Server 2016, you can use the automatically created crawled and managed properties. They make the lives of catalog owners a lot easier.

新的內容新增至目錄 (我們在階段 2: 清單內容匯入至 SharePoint Server 中的產品目錄網站集合中所執行的作業) 後,將會在編目期間發現許多新項目 (我們在階段 4: 設定搜尋並啟用在 SharePoint Server 中的目錄內容的編目中所執行的作業)。為了避免必須建立新的 Managed 屬性,以及將此屬性對應至對應的編目屬性,SharePoint Server 2016 會為您執行這項作業。將目錄編目後,SharePoint Server 2016 會自動為目錄中的每個網站欄建立編目屬性。SharePoint Server 2016 也會自動為網站欄建立 Managed 屬性,並新增兩者之間的對應。When new content is added to a catalog (what we did in Stage 2: Import list content into the Product Catalog Site Collection in SharePoint Server), many new items will be discovered during a crawl (what we did in Stage 4: Set up search and enable the crawling of your catalog content in SharePoint Server). To avoid having to create a new managed property, and map this to the corresponding crawled property, SharePoint Server 2016 does this for you. When a catalog is crawled, SharePoint Server 2016 automatically creates a crawled property for each site column in the catalog. SharePoint Server 2016 also automatically creates a managed property for the site column, and adds a mapping between the two.

重要

只有包含值的 網站欄 會在編目時自動成為 Managed 屬性。一般欄則不會!Only site columns that contain values automatically become managed properties when they are crawled. Regular columns do not!

所以,這是個很棒的做法!So, that is a sweet deal!

但請記得,當您在搜尋網頁組件中設定精簡器和查詢時,您將在後續階段中使用編目和 Managed 屬性。若要執行該作業,請務必了解這些自動建立之編目和 Managed 屬性的名稱建構方式。But, remember that you'll use crawled and managed properties in later stages, when you configure refiners and queries in Search Web Parts. Well, to do that, it's important that you understand how the names of these automatically created crawled and managed properties are constructed.

關於自動建立之編目和 Managed 屬性的命名慣例About the naming convention for automatically created crawled and managed properties

自動建立之屬性的名稱結合了網站欄名稱和網站欄類型。此命名慣例是有點難以理解。讓我們從具有兩個網站欄的簡單範例著手,然後再繼續說明可套用至所有網站欄類型的規則。The name of an automatically created property is a combination of the site column name, and the site column type. This naming convention is a bit tricky to understand. So let's start with a simple example with two site columns, and then move to an explanation of the rules that apply to all site column types.

兩個網站欄類型的命名慣例Naming convention for two site column types

網站欄目的地內容

  1. 產品 清單中,我們有:In the Products list, we have:

    • 名為 "Contoso Color" 且類型為「單行文字」的網站欄A site column named "Contoso Color" of type "Single line of text"

    • 名為 "Contoso Weight" 且類型為「數字」的網站欄A site column named "Contoso Weight" of type "Number"

  2. 在編目期間,系統會針對網站欄自動建立編目屬性。移除網站欄名稱中的空格,並新增一個前置詞,即可產生此屬性的名稱。視網站欄類型而定,新增的前置詞會有所不同。During a crawl, a crawled property is automatically created for the site column. The name of this property is generated by removing spaces from the site column name, and adding a prefix. The prefix that is added varies, depending on the site column type.

    在這個範例中,我們會取得下列編目屬性:In this example, we get the following crawled properties:

    • ows_q_TEXT_ContosoColorows_q_TEXT_ContosoColor

    • ows_q_NMBR_ContosoWeightows_q_NMBR_ContosoWeight

  3. 然後會自動建立 Managed 屬性,並將它對應至對應的編目屬性。移除網站欄名稱中的空格,並新增一個後置詞,即可產生此屬性的名稱。視網站欄類型而定,新增的後置詞會有所不同。A managed property is then automatically created and mapped to the corresponding crawled property. The name of this property is generated by removing spaces from the site column name, and adding a suffix. The suffix that is added varies, depending on the site column type.

    在這個範例中,我們會取得下列 Managed 屬性:In this example, we get the following managed properties:

    • ContosoColorOWSTEXTContosoColorOWSTEXT

    • ContosoWeightOWSNMBRContosoWeightOWSNMBR

這很簡單,對嗎?但是,命名慣例會隨著網站欄類型而改變。That was simple, right? But, the naming convention does vary depending on the site column type.

所有網站欄類型的命名慣例Naming convention for all site column types

建立自動建立的 編目屬性 名稱時,適用下列慣例:For creating an automatically created crawled property name, the following conventions apply:

  • 從網站欄名稱中移除空格。Spaces are removed from the site column name.

  • 若為 [發佈 HTML]**** 和 [多行文字]**** 類型的網站欄,下列前置詞會新增至網站欄名稱:ows_r_<4 個字母代碼>_For site columns of type Publishing HTML and Multiple line of text, the following prefix is added to the site column name: ows_r__

  • 若為 [Managed 中繼資料]**** 類型的網站欄,下列前置詞會新增至網站欄名稱:ows_taxId_For site columns of type Managed Metadata, the following prefix is added to the site column name: ows_taxId

  • 對於所有其他網站欄類型,下列前置詞會新增至網站欄名稱: ows_q_<4 個字母代碼>_For all other site column types, the following prefix is added to the site column name: ows_q_<four letter code>_

建立自動 Managed 屬性 名稱時,適用下列慣例:For creating an automatically managed property name, the following conventions apply:

  • 從網站欄名稱中移除空格Spaces are removed from the site column name

  • 若為 [Managed 中繼資料]**** 類型的網站欄,下列前置詞會新增至網站欄名稱:ows_taxIdFor site columns of type Managed Metadata, the following prefix is added to the site column name: ows_taxId

  • 對於所有其他網站欄類型,下列後置詞會新增至網站欄名稱: OWS <4 個字母代碼>For all other site column types, the following suffix is added to the site column name: OWS <four letter code>

如果您想要更多資訊,在 SharePoint Server 中自動建立 managed 的屬性中有一個概觀表包含所有網站欄類型的範例。If you want more information, there is an overview table with examples for all site column types in Automatically created managed properties in SharePoint Server.

我們的簡單範例簡單明瞭,但此規則有一個例外狀況...That might not have been as straightforward as our simple example, and there is one exception to the rule…

產品清單中預設網站欄的命名慣例Naming convention for the default site columns in the Products list

此例外狀況適用於預設與「產品目錄網站集合」中的 產品 清單相關聯的六個網站欄,如下表所示:This exception applies to the six site columns that by default are associated with the Products list in the Product Catalog Site Collection, as shown in the following table:

網站欄名稱Site column name 編目屬性名稱Craweld property name Managed 屬性名稱Managed property name
項目編號Item Number
ows_q_TEXT_ProductCatalogItemNumberows_q_TEXT_ProductCatalogItemNumber
ProductCatalogItemNumberOWSTEXTProductCatalogItemNumberOWSTEXT
群組編號Group Number
ows_q_TEXT_ProductCatalogGroupNumberows_q_TEXT_ProductCatalogGroupNumber
ProductCatalogGroupNumberOWSTEXTProductCatalogGroupNumberOWSTEXT
語言標記Language Tag
ows_q_CHCS_ProductCatalogLanguageTagows_q_CHCS_ProductCatalogLanguageTag
ProductCatalogLanguageTagOWSCHCSProductCatalogLanguageTagOWSCHCS
項目類別Item Category
ows_taxId_ProductCatalogItemCategoryows_taxId_ProductCatalogItemCategory
owstaxIdProductCatalogItemCategoryowstaxIdProductCatalogItemCategory
彙總圖像Rollup Image
ows_r_IMGE_PublishingRollupImageows_r_IMGE_PublishingRollupImage
PublishingImagePublishingImage

現在了解理論之後,讓我們繼續進行一些具體工作。Now, after all that theory, let's move on to some concrete work.

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

階段 5: 將您的發佈網站連線至 SharePoint Server 中目錄Stage 5: Connect your publishing site to a catalog in SharePoint Server

另請參閱See also

概念Concepts

SharePoint Server 的搜尋結構描述概觀Overview of the search schema in SharePoint Server