Sitecore 计算索引字段 - 如何存储未标记的

Sitecore computed index fields - how to store untokenized

带有默认 lucene 的 Sitecore 8.1。我使用带有计算字段的自定义索引来存储多列表字段的真实值,而不是 guid。这有效,我可以在 Luke 工具中看到该字段被索引为文本。

有些值包含空格,但我希望将这些作为整个字段编入索引。问题是这些以标记化的方式被索引,例如 'Little Hampton' 被索引为 'Little' 和 'Hampton'.

如何让计算字段以未标记的方式存储?请参阅 raw:AddComputedIndexField 部分:

<indexConfigurations>
    <myCustomIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
    <indexAllFields>true</indexAllFields>
    <initializeOnAdd>true</initializeOnAdd>
    <analyzer ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/analyzer" />
    <fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
        <fieldNames hint="raw:AddFieldByFieldName">
        <!-- you must have _uniqueid or you wont be able to update the document later -->
            <field fieldName="_uniqueid" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
            <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
            </field>
            <field fieldName="title" storageType="YES" indexType="UNTOKENIZED" vectorType="YES" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
            <field fieldName="summary" storageType="NO" indexType="TOKENIZED" vectorType="YES" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />  
        </fieldNames>
    </fieldMap>
    <fields hint="raw:AddComputedIndexField">
        <!-- resolves selected guids to text values -->
        <field storageType="NO" indexType="UNTOKENIZED" fieldName="my multilist field">My.CoolStuff.Class, My.CoolStuff</field>
    </fields>

我已经尝试将 storageType="NO" indexType="UNTOKENIZED" 添加到该字段但没有影响,它仍然保持 tozenized 和存储。

尝试将您的计算字段添加到常规 <fieldNames hint="raw:AddFieldByFieldName"> 部分以及计算字段,并指定一个分析器。

例如:

<fieldNames hint="raw:AddFieldByFieldName">
  <field fieldName="my multilist field" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
    <Analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
  </field>
</fieldNames>

我可以为您推荐一件事,它应该有效:

创建一个计算字段,将标题字段中的 spaces 替换为“_”,当您搜索时,将搜索关键字中的任何 space 替换为“_”,这样您的喜欢:Little_Hampton