7

After successfully installing SI4T and setting up an indexer for Elasticsearch, we've been happily indexing our pages. However when we try and index an DCP nothing is appearing in Elasticsearch.

These are DCPs not added on to the page.

I traced this back to the TBBs - Template Builder is logging the following when I debug my dynamic template:

GenerateIndexData: <indexdata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><publicationid>0</publicationid><schemaid>0</schemaid><itemtype>0</itemtype><parentsgid>0</parentsgid><type>0</type></indexdata>
AddIndexData: Found Search Index Data in package: 
AddIndexData: No Search Index Data (package item : SI4T.Templating.SearchData) found - nothing to do

When I look at the GenerateIndexData code I see a check on template context first:

    if (this.IsPageTemplate)
        {
            UpdateFlaggedDcps(data.ProcessPage(this.GetPage()));
        }
        else
        {
            data.ProcessComponentPresentation(
                new Tridion.ContentManager.CommunicationManagement.ComponentPresentation(this.GetComponent(), this.GetComponentTemplate()),
               GetFlaggedDcps());    
        }

In our DCP case we should be executing the else side of this if so the output of GetFlaggedDcps() is called and passed to the data.ProcessComponentPresentation method along with a ComponentPresentation.

The problem (I think) is GetFlaggedDcps():

public virtual List<string> GetFlaggedDcps()
{
    return m_Engine.PublishingContext.RenderContext.ContextVariables[Constants.CONTEXT_VARIABLE_FLAGGED_DCPS] as List<string>;
}

In our DCP case this will return NULL not an empty List<string> - as there is no ContextVariable in the RenderContext.

This then short circuits the the data.ProcessComponentPresentation method which is checking for not NULL (amongst other things, I've checked template priority greater than the minimum):

 public virtual void ProcessComponentPresentation(ComponentPresentation cp, List<string> flaggedDcps)
    {
        string id = GetDcpIdentifier(cp);
        // Bitwise AND - all conditions must be true
        if (cp.ComponentTemplate.IsIndexed(_processor.MinimumComponentTemplatePrio) && flaggedDcps != null && !flaggedDcps.Contains(id))
        {
            this.Url = GetUrlForDcp(cp);
            FieldProcessorSettings settings = cp.ComponentTemplate.GetFieldProcessorSettings();
            ProcessComponent(cp.Component, settings);
        }
    }

Hence I think the execution drops out an no search index data is created. To avoid this my guess would be that the GetFlaggedDcps() should check for null and return an empty List<string>.

(I know this kind of thing causes some consternation here!)

Is my understanding of the code correct - or is there something else I need to check to get DCPs indexed?

Kind regards

1 Answer 1

7

Spot on with your analysis Neil. I tried it out myself just now and experienced the same. The best resolution is to update that conditional logic to be:

if (cp.ComponentTemplate.IsIndexed(_processor.MinimumComponentTemplatePrio) 
    && (flaggedDcps == null || !flaggedDcps.Contains(id)))

I just updated the master branch on Github to reflect this.

4
  • Thanks Will. Have you updated the latest release DLL or do we need to build this from source ourselves?
    – Neil
    Commented Sep 19, 2014 at 9:15
  • No, you need to build this yourselves - I just fixed the code
    – Will Price
    Commented Sep 19, 2014 at 9:37
  • I notice they're built against 2011 SP1 HR1 dlls? Any reason why I couldn't build them against 2013 SP1?
    – Neil
    Commented Sep 19, 2014 at 11:49
  • That will work fine (my dev setup uses the same code built against 2013 SP1) - they are using 2011 for backwards compatibility
    – Will Price
    Commented Sep 19, 2014 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.