在 SharePoint Server 中建立及部署同義字

適用于:yes-img-132013 yes-img-16 2016yes-img-192019 yes-img-se訂閱版本 no-img-sopMicrosoft 365 中的 SharePoint

使用同義字檔案來指定在傳統搜尋體驗的查詢中發生的單一字組或多個單字的同義字。 查詢的範圍會隨同義字字典中的項目數量而異。 您可以先在 SharePoint Server 的外部系統上建立及維護同義字字典檔案,然後再將其匯入 SharePoint Server 中,讓搜尋系統可以使用其中的同義字。

注意事項

每個 SharePoint Server 伺服器陣列只可以部署一個同義字字典。

建立同義字字典

定義同義字字典中的項目時,必須輸入詞彙及其對應的同義字,然後儲存為逗號分隔 (.csv) 的檔案。 您也可以指定要以何種語言寫入所要套用之同義字的查詢。

若同一個索引鍵要定義多個同義字,您必須在同義字字典中建立多個項目。 此外,若要讓同義字雙向運作,例如,若要讓 "IE" 一詞傳回 "Internet Explorer" 的搜尋結果,同時讓 "Internet Explorer" 一詞傳回 "IE" 的搜尋結果,您必須建立兩個同義字項目。

若要建立同義字字詞,您可以使用字母順序的 Unicode 字元,例如 a、ø、ü 或 é。 您的字詞也可以包含底線 (_) 、連字號 () ,以及直單引號 () 。 您的字詞不能包含非字母的 Unicode 字元,例如雜湊標籤 (#) 、斜線 (/) 、反斜線 (\) 、句號 (.) 或問號 (?) 。 您也無法使用包含不按字母排序的 Unicode 字元縮寫,例如 E.K.G 或 d\r。

同義字索引鍵與查詢字詞之間的比對不會區分大小寫。 當查詢字詞符合同義字索引鍵時,查詢會擴及該索引鍵的同義字,且搜尋結果將會包含原始查詢字詞與同義字的結果。

若要建立同義字

  1. 建立內含 [索引鍵]、[同義字]及 [語言] 等欄的 .csv 檔案。 請務必使用逗號分隔各欄。 If the file contains non-ASCII characters such as diacritics, you must encode it in UTF-8. Save the file to a location that is accessible from the server from which you will run the Microsoft PowerShell cmdlet to deploy the thesaurus.

    • In the Key column, enter the term (single or multiple words) that you want to trigger a synonym for when the term occurs in a query. 請注意,詞彙前後不可有空格。

    • 在 [同義字] 欄中,輸入當查詢中出現 [索引鍵] 欄所指定的詞彙時,要加入查詢中的同義字 (單一字詞或多個字詞)。 由多個字詞組成的同義字會以片語形式加入查詢。

    • In the optional Language column, enter the abbreviation for the language for which the synonym should apply. See the table in Linguistic search features in SharePoint Server for an overview of available languages and their code. If you leave this column empty, the query is expanded with the synonym regardless of the query language. 請確認語言代碼前後沒有前置空格或尾端空格。

同義字字典通常用來展開縮寫。 但是,您也可以使用同義字字典將搜尋字詞的變化自動納入到查詢中,用於貴組織中的特定術語。 範例同義字檔案輸入看起來可能像這樣:Key,Synonym,Language IE,Internet Explorer Internet Explorer,IE UN,United Nations,en UN,Vereinte Nationen,de BAM,billing and account management billing and account management,billing and accounts

部署同義字字典

您可以先在 SharePoint Server 的外部系統上建立及維護同義字字典檔案,然後再將其匯入 SharePoint Server 中,讓搜尋系統可以使用其中的同義字。 您無法從 SharePoint Server 匯出同義字字典。 若要變更同義字,必須先更新同義字字典檔案,然後再加以重新部署。

注意事項

當您重新部署同義字字典檔案時,會以更新後的同義字字典檔案的資訊覆寫現有的同義字字典檔案。

若要匯入同義字檔案

  1. 確認執行此程序的使用者帳戶是否為 Search Service 應用程式的管理員。

  2. 啟動 SharePoint 管理命令介面。

  3. 在 Windows PowerShell 命令提示字元處,輸入下列命令:

    $searchApp = Get-SPEnterpriseSearchServiceApplication
    Import-SPEnterpriseSearchThesaurus -SearchApplication $searchApp -Filename <Path>
    

    其中:

    • <路徑> 指定要匯入之 .csv 檔案 (同義字字典) 的完整 UNC 路徑。

另請參閱

SharePoint Server 中的語言搜尋功能

Import-SPEnterpriseSearchThesaurus