Timon
Timon

Reputation: 1013

sitecore IComputedIndexField class isn't found / doens't run

I've added a ComputedIndexFields.config files with the following code:

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

I also added a class in said assemlby:

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

I wanted to test the little bit of code i had already written. So i added a breakpoint at the first line of the "ComputeFieldValue(IIndexable indexable)" method and fired up the website ( while debugging ).

I changed several items, saved them en then rebuild the index tree but my breakpoint is never hit.

The class is located in a different project and build into a .dll with the assemblyname "be.extensions"

I'm using sitecore 8 update 2.

Does anyone know what i did wrong or why this code wouldn't be reached ? ( Like is this code send to some Lucene workflow that i simply can not debug )

Upvotes: 3

Views: 1797

Answers (1)

Derek Hunziker
Derek Hunziker

Reputation: 13141

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>

Upvotes: 3

Related Questions