3

我添加了一个带有以下代码的 ComputedIndexFields.config 文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <indexConfigurations>
         <defaultIndexConfiguration>
          <fields hint="raw:AddComputedIndexField">
            <field fieldName="AppliedThemes" storageType="yes" indexType="TOKENIZED">be.extensions.AppliedThemes, be.extensions</field>
          </fields>
        </defaultIndexConfiguration>
      </configuration>
    </contentSearch>
  </sitecore>
</configuration>

我还在所说的 assmlby 中添加了一个类:

namespace be.extensions
{
    class AppliedThemes : IComputedIndexField
    {

        public string FieldName { get; set; }
        public string ReturnType { get; set; }

        public object ComputeFieldValue(IIndexable indexable)
        {
        Item item = indexable as SitecoreIndexableItem;
        if (item == null)
            return null;

        var themes = item["Themes"];
        if (themes == null)
            return null;

        // TODO
        }
    }
}

我想测试我已经编写的一小段代码。所以我在“ComputeFieldValue(IIndexable indexable)”方法的第一行添加了一个断点并启动了网站(在调试时)。

我更改了几个项目,将它们保存然后重建索引树,但我的断点从未被命中。

该类位于不同的项目中,并构建到具有程序集名称“be.extensions”的 .dll 中

我正在使用 sitecore 8 更新 2。

有谁知道我做错了什么或为什么无法访问此代码?(就像这段代码发送到一些我根本无法调试的 Lucene 工作流一样)

4

1 回答 1

3

Your configuration is likely not being patched in due to a change Sitecore made to the structure of the Include file. Namely, the defaultIndexConfiguration node was changed to defaultLuceneIndexConfiguration along with a new type attribute. You can verify that your computed field is being patched correctly using the /sitecore/admin/showconfig.aspx utility page. Also, please note that the storageType and indextype for each computed index field is now defined in the <fieldMap><fieldNames> section, not where you have it now.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <indexConfigurations>
        <defaultLuceneIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
          <fields hint="raw:AddComputedIndexField">
            <field fieldName="yourname">be.extensions.AppliedThemes, be.extensions</field>
          </fields>
        </defaultLuceneIndexConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>
于 2015-04-16T16:27:04.860 回答