在 SharePoint Server 中建立及部署同義字Create and deploy a thesaurus in SharePoint Server

摘要: 了解如何建立及部署同義字字典,以拓展同義字查詢的範圍。Summary: Learn how to create and deploy a thesaurus to expand queries with synonyms.

使用同義字字典檔案可指定查詢所含之單一字詞或多個字詞的同義字。查詢的範圍會隨同義字字典中的項目數量而異。您可以先在 SharePoint Server 的外部系統上建立及維護同義字字典檔案,然後再將其匯入 SharePoint Server 中,讓搜尋系統可以使用其中的同義字。Use a thesaurus file to specify synonyms for a single word or multiple words that occur in queries. The query is expanded based on the entries in the thesaurus. You create and maintain the thesaurus file in a system external to SharePoint Server before you import it into SharePoint Server to make the synonyms available to the search system.

注意

每個 SharePoint Server 伺服器陣列只可以部署一個同義字字典。You can only deploy one thesaurus per SharePoint Server farm.

建立同義字字典Create a thesaurus

定義同義字字典中的項目時,必須輸入詞彙及其對應的同義字,然後儲存為逗號分隔 (.csv) 的檔案。您也可以指定要以何種語言寫入所要套用之同義字的查詢。To define the entries in your thesaurus, you enter terms and their corresponding synonyms in a comma separated (.csv) file. Optionally, you can also specify in which language the query should be written for a synonym to apply.

若同一個索引鍵要定義多個同義字,您必須在同義字字典中建立多個項目。此外,若要讓同義字雙向運作,例如,若要讓 "IE" 一詞傳回 "Internet Explorer" 的搜尋結果,同時讓 "Internet Explorer" 一詞傳回 "IE" 的搜尋結果,您必須建立兩個同義字項目。If you want to define more than one synonym for one key, you have to create multiple entries in the thesaurus. Also, if you want the synonym to work both ways, for example, if you want the term "IE" to also return search results for "Internet Explorer" and you want the term "Internet Explorer" to also return results for "IE", you have to create two thesaurus entries.

若要建立同義字字詞,您可以使用按字母排序的 Unicode 字元,例如 a, ø, ü或é。您的字詞也可以包含底線 ()、連字號 (-) 和直線單引號 (')。您的字詞不能包含不按字母排序的 Unicode 字元,例如雜湊標記 (#)、斜線 (/)、反斜線 ()、標點符號 (.) 或問號 (?)。您也無法使用包含不按字母排序的 Unicode 字元縮寫,例如 E.K.G 或 d\r。To create your thesaurus terms, you can use alphabetical Unicode characters such as a, ø, ü or é. Your terms can also include underscores (), hyphens (-) and straight apostrophes ('). Your terms can't include non-alphabetical Unicode characters, such as hashtag (#), forward slash (/), back slash () , punctuation (.) or question mark (?). You also can't use abbreviations that include non-alphabetical Unicode characters, such as E.K.G or d\r.

同義字索引鍵與查詢字詞之間的比對不會區分大小寫。當查詢字詞符合同義字索引鍵時,查詢會擴及該索引鍵的同義字,且搜尋結果將會包含原始查詢字詞與同義字的結果。The matching between the thesaurus keys and query terms is not case sensitive. When a query term matches a thesaurus key, the query is expanded with the synonym(s) for that key and the search results will contain results for the original query term as well as for the synonym.

建立同義字字典To create a thesaurus

  1. 建立內含 [索引鍵]*、[同義字]* 及 [語言]**** 等欄的 .csv 檔案。請務必使用逗號分隔各欄。若檔案包含非 ASCII 字元 (例如讀音符號),您必須使用 UTF-8 加以編碼。儲存檔案時,請將其儲存到可以從伺服器存取,且您可從該伺服器執行 Microsoft PowerShell Cmdlet 以部署同義字的位置上。Create a .csv file with the columns Key, Synonym and Language. Make sure you use a comma as the column separator. 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 PowerShell_1st_NoVer 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. Make sure there are no leading or trailing spaces around the terms.

    • 在 [同義字]**** 欄中,輸入當查詢中出現 [索引鍵]**** 欄所指定的詞彙時,要加入查詢中的同義字 (單一字詞或多個字詞)。由多個字詞組成的同義字會以片語形式加入查詢。In the Synonym column, enter the synonym (single or multiple words) that you want to add to the query if the term specified in the Key column occurs in a query. Synonyms consisting of multiple words will be added as phrases to the query.

    • 在選用的 [語言]**** 欄中,輸入同義字適用語言的縮寫。如需可用語言及其代碼的概觀,請參閱 Linguistic search features in SharePoint Server 中的表格。若將此欄留空,查詢會擴及所有同義字而忽略查詢語言。請確認語言代碼前後沒有前置空格或尾端空格。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 2013 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. Make sure there are no leading or trailing spaces around the language codes.

同義字字典通常用來展開縮寫。但是,您也可以使用同義字字典將搜尋字詞的變化自動納入到查詢中,用於貴組織中的特定術語。範例同義字檔案輸入看起來可能像這樣: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 accountsA thesaurus is commonly used to expand acronyms. But you can also use a thesaurus to automatically include variations of a search term into the query for specific terminology used in your organization. An example thesaurus file input could look like this: 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

部署同義字字典Deploy a thesaurus

您可以先在 SharePoint Server 的外部系統上建立及維護同義字字典檔案,然後再將其匯入 SharePoint Server 中,讓搜尋系統可以使用其中的同義字。您無法從 SharePoint Server 匯出同義字字典。若要變更同義字,必須先更新同義字字典檔案,然後再加以重新部署。You create and maintain the thesaurus file in a file external to SharePoint Server before you import it into SharePoint Server to make the synonyms available to the search system. You can't export a thesaurus from SharePoint Server. If you want to make changes to your synonyms, you have to update the thesaurus file and then redeploy it.

注意

當您重新部署同義字字典檔案時,會以更新後的同義字字典檔案的資訊覆寫現有的同義字字典檔案。When you redeploy a thesaurus file, the existing thesaurus will be overwritten with the information from the updated thesaurus file.

匯入同義字字典檔案To import a thesaurus file

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

  2. 啟動 SharePoint 管理命令介面。Start the SharePoint Management Shell.

  3. 在 Windows PowerShell 命令提示字元下,輸入下列命令: At the Windows PowerShell command prompt, type the following command:

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

    其中:Where:

    • <路徑> 指定要匯入之 .csv 檔案 (同義字字典) 的完整 UNC 路徑。<Path> specifies the full UNC path of the .csv file (the thesaurus) to be imported.

另請參閱See also

SharePoint Server 中的語言搜尋功能Linguistic search features in SharePoint Server

Import-SPEnterpriseSearchThesaurusImport-SPEnterpriseSearchThesaurus