3

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 )

Timon
  • 1,003
  • 1
  • 9
  • 38
  • What does /sitecore/admin/showconfig.aspx tell you? Is the patch file getting included? – Ian Graham Apr 16 '15 at 16:05
  • when you say, fired up the website, is your project and your website root in the same location? are you attached to the correct debug process? does your webroot contain the .pdb for your assembly? – Elena Mosoff Apr 16 '15 at 16:06

1 Answers1

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>
Derek Hunziker
  • 12,996
  • 4
  • 57
  • 105