使用英语阅读

通过


使用 Windows PowerShell 执行 CJK(中文、日语和朝鲜语)特定的词汇切分任务 (FAST Search Server 2010 for SharePoint)

 

适用于: FAST Search Server 2010

上一次修改主题: 2015-03-09

在 FAST Search Server 2010 for SharePoint 中,您可以使用两种方法影响默认词汇切分:语言词汇切分子字符串词汇切分

语言词汇切分

语言词汇切分表示根据特定语言规则将一个文本字符串拆分为单个标记。对于东亚语言,可通过创建自定义词典来影响词汇切分。如果 FAST Search Server 2010 for SharePoint 提供的系统词典中缺少单词(例如技术术语、人名或公司名称),或者默认词汇切分不正确,则可以向自定义词典中添加单词以确保根据需要对它们进行标记。

子字符串词汇切分

对于检索次数非常重要的应用程序,子字符串词汇切分尤其有用。子字符串词汇切分会移除文本中的所有空格,然后将其拆分为双字母组(与两个字符的长标记重叠)。例如“アメリカ” (美国) 可拆分为: ア,アメ,メリ,リカ (a、ame、meri、ca)。

子字符串词汇切分会增加检索次数,但会降低精确度并显著增加索引的大小。如果减小索引大小比增加检索次数更为重要,则不要使用子字符串词汇切分。为尽可能不降低精确度,可以结合使用子字符串词汇切分和语言词汇切分。

提示

如果您仅使用子字符串词汇切分,而不使用任何语言词汇切分,则精确度将非常低。通常情况下,语言标记化索引中命中项的排名要高于子字符串标记化索引中命中项的排名。因此,两种词汇切分类型的组合将提供最佳的精确度和检索。

本文内容:

  • 为东亚分词系统创建自定义词典(语言词汇切分)

  • 配置子字符串词汇切分

  • 配置语言词汇切分和子字符串词汇切分的组合

为东亚分词系统创建自定义词典(语言词汇切分)

  1. 确认您满足以下最低要求:您是安装了 FAST Search Server 2010 for SharePoint 的计算机上的 FASTSearchAdministrators 本地组的成员。

  2. 在文本编辑器中打开一个新文件。

  3. 根据以下规则,在自定义词典中键入所需的词:

    • 第一行必须为 #CUSTOMER_WB

    • 请勿使用 # 字符作为条目的第一个字符。

    • 请勿在条目中使用空格。

    • 使用正斜杠 (/) 标记复合词中的标记边界。朝鲜语自定义词典不支持将条目标记为复合词。

      示例:

      • 英语: book/shelf/cover

      • 日语/中文: 朝鲜/民主/主義/人民/共和國

      • 泰语: กระทรวง/มหาด/ไทย

    • 使用以下文件名:

      语言 文件名

      日语

      custom0011.lex

      朝鲜语

      includeKOR.txt

      泰语

      custom001e.lex

      简体中文

      custom0804.lex

      繁体中文

      custom0404.lex

  4. 在“文件”菜单上,单击“另存为”。

  5. 在“保存类型”列表中,选择“所有文件”。

  6. 在“编码”列表中,选择“Unicode”。

  7. 在每台执行 FAST Search Server 2010 for SharePoint 搜索或项目处理的服务器上的 <FASTSearchInstallationFolder>\lib\nlg\ 文件夹中保存自定义词典(<FASTSearchInstallationFolder> 是您安装 FAST Search Server 2010 for SharePoint 的文件夹的路径,例如 C:\FASTSearch)。

  8. 在“开始”菜单上,单击“所有程序”。

  9. 单击“Microsoft FAST Search Server 2010 for SharePoint shell”。

  10. 单击“Microsoft FAST Search Server 2010 for SharePoint shell”。

  11. 在 Windows PowerShell 命令提示符处,通过键入以下命令重新启动项目处理和查询处理:

    psctrl reset
    nctrl restart qrserver
    
  12. 重新对所有内容进行爬网以启用索引内容的自定义项。

备注

根据语言不同,自定义词典中的单词处理方式也不同。
对于中文、日语和泰语,在词汇切分过程中将为自定义词典中的单词提供绝对优先级。如果在自定义词典中找到某个单词,则会保证按照自定义词典中的定义,对文档中的同一单词进行标记。
对于韩语,自定义词典中定义的词汇切分只会增加特定词汇切分的可能性。

配置子字符串词汇切分

使用此过程可禁用语言词汇切分并启用字字符串词汇切分:

  1. 确认您满足以下最低要求:您是安装了 FAST Search Server 2010 for SharePoint 的计算机上的 FASTSearchAdministrators 本地组的成员。

  2. 在 FAST Search Server 2010 for SharePoint 管理服务器上,在文本编辑器中打开 <FASTSearchInstallationFolder> components\admin-services\web.config(<FASTSearchInstallationFolder> 是您安装 FAST Search Server 2010 for SharePoint 的文件夹的路径,例如 C:\FASTSearch)。通过将 AllowIndexPurgeOnSchemaUpdate 的值设置为yes,自动为所有项目重新编制索引。

  3. 保存该文件。

  4. 在“开始”菜单上,单击“所有程序”。

  5. 单击“Microsoft FAST Search Server 2010 for SharePoint”。

  6. 单击“Microsoft FAST Search Server 2010 for SharePoint Shell”。

  7. 在 Windows PowerShell 命令提示符处,键入以下命令:

    $mp= Get-FASTSearchMetadataManagedProperty -name <ManagedPropertyName>
    

    其中:

    • <ManagedPropertyName> 为您要为其配置子字符串词汇切分的托管属性的名称,例如 title。
  8. 查看托管属性的属性:

    $mp
    
    >> Name                                   :         Title
    >> Description                            :         The title of the document
    >> Type                                   :         Text
    >> Queryable                              :         True
    >> StemmingEnabled                        :         True
    >> RefinementEnabled                      :         False
    >> MergeCrawledPfopertiesAuthorityWeight  :         False
    >> SubstringEnabled                       :         False
    >> DeleteDisallowed                       :         True
    >> MappingDisallowed                      :         False
    >> MaxIndexSize                           :         1024
    >> MaxResultSize                          :         64
    >> DecimalPlaces                          :         3
    >> SortableType                           :         SortableDisabled
    >> SummaryType                            :         Dynamic   
    
  9. 禁用词干分解:

    $mp.StemmingEnabled=0
    
  10. 启用子字符串:

    $mp.SubstringEnabled=1
    
  11. 更新托管属性:

    $mp.Update()
    
  12. 确保已进行了更改:

    $mp
    
    >> Name                                   :         Title
    >> Description                            :         The title of the document
    >> Type                                   :         Text
    >> Queryable                              :         True
    >> StemmingEnabled                        :         False
    >> RefinementEnabled                      :         False
    >> MergeCrawledPfopertiesAuthorityWeight  :         False
    >> SubstringEnabled                       :         True
    >> DeleteDisallowed                       :         True
    >> MappingDisallowed                      :         False
    >> MaxIndexSize                           :         1024
    >> MaxResultSize                          :         64
    >> DecimalPlaces                          :         3
    >> SortableType                           :         SortableDisabled
    >> SummaryType                            :         Dynamic   
    

    运行 Update() 命令后,需要等待几分钟才能启用子字符串词汇切分。请等待几分钟,然后再馈送文档。

  13. 重新对所有内容进行爬网。

配置语言词汇切分和子字符串词汇切分的组合

若要组合两种词汇切分模式,必须创建两个全文索引和两组托管属性。一个索引/属性对启用子字符串词汇切分 (SubstringEnabled=1),另一个索引/属性对则启用语言词汇切分 (StemmingEnabled=1)。

如果您希望这两个托管属性在搜索结果中分配有不同的排名,则必须将这两个托管属性映射到不同的全文索引。

下面的示例过程介绍了如何同时将子字符串词汇切分和语言词汇切分应用到托管属性:

  1. 确认您满足以下最低要求:您是安装了 FAST Search Server 2010 for SharePoint 的计算机上的 FASTSearchAdministrators 本地组的成员。

  2. 在 FAST Search Server 2010 for SharePoint 管理服务器上,在文本编辑器中打开 <FASTSearchInstallationFolder>\components\admin-services\web.config(<FASTSearchInstallationFolder> 是您安装 FAST Search Server 2010 for SharePoint 的文件夹的路径,例如 C:\FASTSearch)。通过将 AllowIndexPurgeOnSchemaUpdate 的值设置为 yes,自动为所有项目重新编制索引。

  3. 保存该文件。

  4. 在“开始”菜单上,单击“所有程序”。

  5. 单击“Microsoft FAST Search Server 2010 for SharePoint”。

  6. 单击“Microsoft FAST Search Server 2010 for SharePoint Shell”。

  7. 在 Windows PowerShell 命令提示符处,键入以下命令。

    Get-FASTSearchMetadataFullTextIndexMapping -ManagedProperty (Get-FASTSearchMetadataManagedProperty -name <ManagedProperty>)
    
    >> ImportanceLevel:     :  7
    >> ManagedProperty:     :  Title
    >> FullTextIndex:       :  content
    

    其中:

    • <ManagedProperty> 是您要为其配置语言词汇切分和子字符串词汇切分的托管属性的名称,例如 title
  8. 创建与上述托管属性的内容相同的新托管属性:

    $mpSubstring=New-FASTSearchMetadataManagedProperty -name <ManagedProperty>Substring -type 1
    

    其中:

    • <Managed_Property> 是要使用其内容来创建新托管属性的托管属性,例如 title
  9. 查看新托管属性的属性:

    $titleSubstring
    
    >> Name                                   :         titleSubstring
    >> Description                            :         
    >> Type                                   :         Text
    >> Queryable                              :         True
    >> StemmingEnabled                        :         False
    >> RefinementEnabled                      :         False
    >> MergeCrawledPfopertiesAuthorityWeight  :         False
    >> SubstringEnabled                       :         False
    >> DeleteDisallowed                       :         False
    >> MappingDisallowed                      :         False
    >> MaxIndexSize                           :         1024
    >> MaxResultSize                          :         64
    >> DecimalPlaces                          :         3
    >> SortableType                           :         SortableDisabled
    >> SummaryType                            :         Static   
    
  10. 对新的托管属性禁用语言词汇切分:

    $mpSubstring.StemmingEnabled=0
    
  11. 对新的托管属性启用子字符串词汇切分:

    $mpSubstring.SubstringEnabled=1
    
  12. 更新新的托管属性:

    $mpSubstring.update()
    
  13. 若要确保两个托管属性的内容相同,请将第一个托管属性的所有已爬网属性映射到新创建的托管属性:

    Get-FASTSearchMetadataCrawledPropertyMapping -name <ManagedProperty>| ForEach-Object { New-FASTSearchMetadataCrawledPropertyMapping -managedproperty $mpSubstring -crawledproperty $_}
    

    其中:

    • <ManagedProperty> 是用来创建新托管属性的托管属性,例如 title
  14. 仅对全文索引的名称创建带小写字符的新全文索引:

    $mpSubstringIndex= New-FASTSearchMetadataFullTextIndex -Name <NewFullTextIndex> -Description "Title Substring"
    

    其中:

    • <NewFullTextIndex> 是新全文索引的名称,例如 titlesubstringindex
  15. 查看新的全文索引:

    $mpSubstringIndex
    
    >> Name                :   titlesubstringindex
    >> Description         :   Title Substring
    >> StemmingEnabled:    :   True
    >> isDefault           :   False
    >> DeleteDisallowed:   :   False
    
  16. 对新的全文索引禁用语言词汇切分:

    $mpSubstringIndex.StemmingEnabled=0
    
  17. 更新新的全文索引:

    $mpSubstringIndex.Update()
    
  18. 确保已更新新的全文索引:

    $mpSubstringIndex
    
    >> Name                :   titlesubstringindex
    >> Description         :   Title Substring
    >> StemmingEnabled:    :   False
    >> isDefault           :   False
    >> DeleteDisallowed:   :   False
    
  19. 将新创建的启用子字符串的托管属性映射到新创建的启用子字符串的全文索引:

    New-FASTSearchMetadataFullTextIndexMapping -ManagedProperty $<NewManagedProperty> -FullTextIndex $<NewFullTextIndex> -ImportanceLevel 1
    

    其中:

    • <NewManagedProperty> 是新创建的托管属性的名称,例如 titleSubstring

    • <NewFullTextIndex> 是新创建的全文索引的名称,例如 titlesubstringindex

  20. 创建一个新的排名配置文件来包含这两个索引:

    $NewRankProfile=New-FASTSearchMetadataRankProfile -Name <NewRankProfile>
    

    位置

    • <NewRankProfile> 是新排名配置文件的名称,例如 DualRankProfile
  21. 确定您的全文索引在新创建的排名配置文件中是否有预定义的排名要素:

    $DualRankProfile.GetFullTextIndexRanks()
    
    >> FullTextIndexReference    :  content
    >> ProximityWeight           :  50
    >> ContextWeight:            :  50
    

    对于名为 content 的全文索引来说,默认安装中仅有一个预定义的排名要素。

  22. 为尚不具有索引排名的新创建的全文索引创建索引排名要素:

    $mpSubstringIndex= get-FASTSearchMetadataFullTextIndex -Name <NewFullTextIndex>
    $DualRankProfile.CreateFullTextIndexRankComponent($<NewFullTextIndex>)
    

    其中:

    • <NewFullTextIndex> 是刚创建的全文索引的名称,例如 titlesubstringindex
  23. 确认这两个全文索引在排名配置文件中是否具有全文索引排名要素:

    $DualRankProfile.GetFullTextIndexRanks()
    
    >> FullTextIndexReference    :  content
    >> ProximityWeight           :  50
    >> ContextWeight:            :  50
    
    >> FullTextIndexReference    :  titlesubstringindex
    >> ProximityWeight           :  140
    >> ContextWeight:            :  50
    
  24. 包含语言标记化词的全文索引 (content) 的排名应高于带子字符串标记化词的全文索引 (titlesubstringindex)。

    若要让包含语言标记化词的全文索引排名高于带子字符串标记化词的全文索引,请将启用子字符串的全文索引的上下文权重设置为低于语言标记化的全文索引的上下文权重:

    $ranks = $DualRankProfile.GetFullTextIndexRanks()
    $ranks|Where-Object -filterscript {$_.FullTextIndexReference.Name -eq "titlesubstringindex"}|ForEach-Object {$_.ContextWeight=<ContextWeight>; $_.Update()}
    

    其中:

    • <ContextWeight> 是您希望新全文索引 (titlesubstringindex) 具有的相对于默认全文索引 (content) 的上下文权重,例如 30。
  25. 确认已更新上下文权重:

    $DualRankProfile.GetFullTextIndexRanks()
    
    >> FullTextIndexReference    :  content
    >> ProximityWeight           :  50
    >> ContextWeight:            :  50
    
    >> FullTextIndexReference    :  titlesubstringindex
    >> ProximityWeight           :  140
    >> ContextWeight:            :  30