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