Overview
The CrownPeak Search G2 Realtime Indexing enhances the existing search platform by providing a direct connection between the CMS and the Search G2 platform. With this enhancement, assets can be built within the CMS for delivery directly to the Search G2 platform upon publication.
Here are a few use-cases where Realtime Indexing would prove advantageous:
- Time-critical publications where website crawling is too infrequent for Search platform update
- Storing and returning items that otherwise don't need pages that are published to the delivery environment (e.g. office locations when taking advantage of CrownPeak Search's geo-location capability)
- Indexing and querying protected content that cannot be deployed to the delivery environment for security reasons
- Choosing not to use site crawling at all
For more information about CrownPeak Search G2, please visit the Search G2 Introduction page.
Connector
The Architecture for the Search G2 is as follows:
- A new connector type is added to the CMS Configuration Settings
- A connector is created for each Search G2 Collection that will be published to
- An additional setting on a CMS Publishing Package, to tell the CMS which Connector should be used for publishing at each workflow state
- Three new CMS Template Files (search_g2_insert.aspx, search_g2_update.aspx & search_g2_delete.aspx) need to be added
Upon publishing the asset through the CrownPeak CMS, either the search_g2_insert.aspx or search_g2_update.aspx will be executed, depending on whether the action is an initial insert, or subsequent update. Upon un-publication or retirement of an asset from the CrownPeak CMS, the search_g2_delete.aspx template file will be executed, asynchronously sending the CrownPeak Search G2 content insert/update/delete.
Setting up the Connector
The new CrownPeak Search G2Connector is available within the CMS via [Settings] [Configuration] [General Search G2]. (Figure 1)
Note: New Connectors are only configurable by CrownPeak Support.
Figure 1 - Search G2 Connector Configuration
Publishing Package Settings
To inform the CMS which Connector should be used for publishing at each workflow state, a Search G2 setting needs to be set in the Publishing Package using [Settings] [Publishing] [Package] (Figure 2).
Figure 2 - Search G2 option in the Publishing Package
Templates
Three New CMS Template Files have been added as part of this enhancement:
- search_g2_insert.aspx - Executed whenever an Asset is published for the first time;
- search_g2_update.aspx - Executed whenever an Asset is updated and published;
- search_g2_delete.aspx - Executed whenever an Asset is un-published or retired.
Example of code inside search_g2_insert.aspx or search_g2_update.aspx to add content from the current Asset into CrownPeak Search G2:
//set-up the CrownPeak.CMSAPI.Services.SearchG2JsonParams object for document insert/update to CrownPeak Search var doc = new SearchG2JsonParams { /*Id = asset.Id.ToString(), //note that this is not required if the value asset.Id.ToString() is to be used as the document identifier in CrownPeak Search*/ Operation = SearchG2JsonParams.OperationType.Create, //or SearchG2JsonParams.OperationType.Update Overwrite = true //if a document exists with this Id, overwrite it }; doc.Add( "custom_s_language" , "language" ); //custom string field "language", takes value from asset["language"] doc.Add( "custom_s_country" , "country" ); doc.Add( "custom_s_theraputic" , "therapeutic" ); doc.Add( "custom_s_product" , "product" ); doc.Add( "title" , "title" ); doc.Add( "content" , "content" ); doc.Add( "type" , "type" ); doc.AddFixed( "contentLength" , asset.Raw[ "content" ].Length.ToString()); //standard CrownPeak Search field "contentLength", taking value from asset.Raw["content"].Length.ToString() doc.AddFixed( "tstamp" , DateTime.UtcNow.ToString( "O" )); //standard CrownPeak Search field "stamp", taking value from DateTime.UtcNow.ToString("O") doc.Add( "date" , AssetPropertyNames.ModifiedDate); doc.Add( "lastModified" , AssetPropertyNames.ModifiedDate); //add the SearchG2JsonParams document to context.JsonParams collection for insert/update to CrownPeak Search. context.JsonParams.Add(doc); |
Example of code inside search_g2_delete.aspx to delete the current asset from Search G2:
//set-up the CrownPeak.CMSAPI.Services.SearchG2JsonParams object for document delete from CrownPeak Search var doc = new SearchG2JsonParams { /*Id = asset.Id.ToString(), //note that this is not required if the value asset.Id.ToString() is to be used as the document identifier in CrownPeak Search*/ Operation = SearchG2JsonParams.OperationType.Delete }; //add the SearchG2JsonParams document to context.JsonParams collection for delete from CrownPeak Search. context.JsonParams.Add(doc); |
Logging
A record is added to the System Log under 'Custom' in the Action filter when an asset is sent for Realtime Indexing. This log can be viewed under [Reports] [Audit] [System] (Figure 3)
Figure 3 - System Audit Custom Collection Information