In this article you will find:
Table of Contents |
---|
Goal
This article provides information on how to extend the indexing logic for Hawksearch ElasticV4
Prerequisite
Info |
---|
Installed Connector - Installing the Connector |
Building a Custom Search Service
Create a custom search service class and inherit from HawksearchService.
Change the Search Service implementation from Sitefinity’s Advanced Settings (your-website-domain/Sitefinity/Administration/Settings/Advanced) -
Navigate to:
Administration → Settings → Advanced Settings → Search → Search Services → Hawksearch In TypeName field enter your custom search service type name (the namespace plus the name of the class e.g. SitefinityWebApp.Search.CustomSearchService).
Add External Data to the Index
Add additional Fields to the index
...
2. Add additional Fields to Elasticsearch search Document
Code Block |
---|
using Hawksearch.Search; using System.Collections.Generic; using Telerik.Sitefinity.Services.Search.Data; using Telerik.Sitefinity.Services.Search.Model; using Telerik.Sitefinity.Services.Search.Publishing; namespace SitefinityWebApp.Search { public class CustomSearchService : HawksearchService { public override void UpdateIndex(string name, IEnumerable<IDocument> documents) { var documentList = new List<IDocument>(); foreach (var document in documents) { var fields = new List<IField>(); fields.AddRange(document.Fields); var newField = new Field { Name = "your-custom-field-name", Value = "your-custom-field-value" }; fields.Add(newField); var modifiedDocument = new Document(fields, document.IdentityField.Name); documentList.Add(modifiedDocument); } base.UpdateIndex(name, documentList); } } } |
...