Extending Data Indexing in Hawksearch V4L

In this article you will find:

Goal

This article provides information on how to extend the indexing logic for Hawksearch V4L.

Prerequisite

Installed Connector - Installing the Connector

Building a Custom Exporter

You can extend the default implementation of the Writer class using the IoCKernel in Global.asax on the Bootstrapper_Bootstrapped method.

using System; using Hawksearch.SDK; using Hawksearch.SDK.Export.IO; using SitefinityWebApp.Search; using Telerik.Sitefinity.Abstractions; namespace SitefinityWebApp { public class Global : System.Web.HttpApplication { protected void Application_Start(object sender, EventArgs e) { Bootstrapper.Bootstrapped += this.Bootstrapper_Bootstrapped; } private void Bootstrapper_Bootstrapped(object sender, EventArgs e) { IocKernel.Kernel.Rebind<IWriter>().To<CustomWriterClass>(); } } }

Add External Data to the Index

Add additional Field to single V4L Document:

  • Create a class (CustomWriterClass).

  • Inherit the Writer class from the Hawksearch.SDK.Export.IO

  • Override the method AppendAttribute() and add your custom field.

using System.Collections.Generic; using System.Text; using Hawksearch.SDK.Export.IO; using Hawksearch.SDK.Indexing; namespace HawksearchApp.Controllers { public class CustomWriterClass : Writer { protected override void AppendAttribute(string fieldName, List<string> fieldValues, SubmitDocument submitDoc, ref StringBuilder attributesSb) { var attributesLineTemplate = "{0}\t{1}\t{2}"; var id = submitDoc.IdentityField["IdentityField"]; attributesSb.AppendLine( string.Format( attributesLineTemplate, id, "your-custom-field-name", "your-custom-field-value")); base.AppendAttribute(fieldName, fieldValues, submitDoc, ref attributesSb); } } }