c# - 未找到站点核心 IComputedIndex 字段类/未运行

标签 c# indexing lucene sitecore computed-field

我添加了一个包含以下代码的 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>

我还在上述assembly中添加了一个类:

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 update 2。

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

最佳答案

由于 Sitecore 对包含文件的结构进行了更改,您的配置可能未被修补。即 defaultIndexConfiguration节点更改为 defaultLuceneIndexConfiguration以及一个新的类型属性。您可以使用 /sitecore/admin/showconfig.aspx 验证您的计算域是否被正确修补。实用程序页面。另外,请注意 storageTypeindextype每个计算索引字段现在在 <fieldMap><fieldNames> 中定义部分,而不是现在的位置。

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

关于c# - 未找到站点核心 IComputedIndex 字段类/未运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29680126/

相关文章:

c# - 如何在datagridview中显示图片? C#

c# - 屏幕截图中未捕获对话框和菜单更改

MongoDB 需要很长时间才能建立索引

mysql - 在多索引mysql中使用外键索引

search - 每个属性值的Elasticsearch(n)个文档

php - 使用 Solr Lucene 索引不同类型的实体/对象

c# - µ律放大

c# - 尝试在 api 启动后运行方法

c - PostgreSQL:如何实现 GIN?

c# - Lucene.Net 是否仅从最后添加的文档中获取结果?