Adding custom classification to the Sitefinity search index

Adding custom classification to the Sitefinity search index

Posted on September 01, 2015 0 Comments

With the Sitefinity 7.3 release came many improvements to the search and indexing. Out of the box partial match search and indexing of tags and categories to name a few.

Adding the tags and categories to the additional fields for indexing will now automatically translate the guids of the the taxa and add their actual names to the index, allowing users to search in these fields as well.

 Having this for tags and categories is great, however we would want this to work for the custom classifications as well.

I have created three pipes - CustomContentInboundPipe, CustomPagesInboundPipe and CustomDynamicContentInboundPipe and added the logic to achieve this. In the pipes, all the fields for additional indexing are checked and if any of them are of the type taxonomy, the field is processed and the translated taxa are added to the search index.

 You can add the pipes to your application and register them like this:

protected void Application_Start(object sender, EventArgs e)
       {
             Bootstrapper.Initialized += Bootstrapper_Initialized;
           PublishingModule.Configured += PublishingModule_Configured;
       }
       private void PublishingModule_Configured(object sender, EventArgs e)
       {
           // Code for registering the pipes here
           CustomContentInboundPipe.Register();
           CustomPageInboundPipe.Register();
       }
  
void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
       {
               
           if (e.CommandName == "Bootstrapped")
           {
               var modules = ModuleBuilderManager.GetManager().Provider.GetDynamicModuleTypes();
              foreach (var module in modules)
              {
                  var pipeName = string.Format("{0}Pipe", module.GetFullTypeName());
                  PublishingSystemFactory.UnregisterPipe(pipeName);
                  PublishingSystemFactory.RegisterPipe(pipeName, typeof(CustomDynamicContentInboundPipe));
              }
    
                    
           }
       }

After the pipes are registered, all you need to do is add the custom classifications fields to the list of additional fields to be indexed for the search index and run a reindex.

You can download the files from here:

CustomContentInboundPipe

CustomDynamicContentInboundPipe

CustomPageInboundPipe

Atanas Valchev

Atanas Valchev is a Tech Support Engineer at Telerik. He joined the Sitefinity Support team in March 2012.

Comments

Comments are disabled in preview mode.
Topics

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Loading animation