【问题标题】:Sitecore computed index fields - how to store untokenizedSitecore 计算索引字段 - 如何存储未标记的
【发布时间】:2017-01-30 08:09:46
【问题描述】:

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

一些值包含空格,但我希望将它们作为整个字段进行索引。问题是这些以标记化的方式被索引,例如“Little Hampton”被索引为“Little”和“Hampton”。

如何使计算字段未标记化地存储?请参阅原始: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 并存储。

【问题讨论】:

    标签: sitecore lucene.net sitecore8 sitecore8.1 sitecore-lucene


    【解决方案1】:

    尝试将您的计算域添加到常规的&lt;fieldNames hint="raw:AddFieldByFieldName"&gt; 部分,并指定一个分析器。

    例如:

    <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>
    

    【讨论】:

    • 使用计算域的目的是避免存储 guid,而是存储文本。使用您的建议将导致再次存储 guid。
    • 你试过了吗?结合计算字段,它应该按照您的意愿存储值。
    • 我没有尝试过 - 我以为你是在建议而不是添加到配置中。好的,我试过了,它奏效了 :) 但我很困惑 - 这是怎么回事?
    • 我澄清了一点答案。很高兴它奏效了。至于发生了什么,我不确定。我的猜测是 indexType 要么被忽略,要么使用 ComputedFields 以不同方式计算。稍后我会深入研究它,因为我也很好奇。目前,我只知道它有效。
    【解决方案2】:

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

    创建一个计算字段,将标题字段中的空格替换为“_”,当您搜索时,将搜索关键字中的任何空格替换为“_”,这样您的结果将类似于:Little_Hampton

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-13
      • 2016-06-20
      • 1970-01-01
      • 1970-01-01
      • 2019-07-06
      相关资源
      最近更新 更多