Skip to content

Instantly share code, notes, and snippets.

@ismailmayat
Created October 30, 2019 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismailmayat/560e9a722d6347c5dbb1711902228383 to your computer and use it in GitHub Desktop.
Save ismailmayat/560e9a722d6347c5dbb1711902228383 to your computer and use it in GitHub Desktop.
using System;
using System.Globalization;
using Lucene.Net.Documents;
using System.Text;
using Examine;
using Umbraco.Core;
using Umbraco.Core.Logging;
using UmbracoExamine;
namespace BusinessLogic.Events
{
public class ExamineEvents:ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"].GatheringNodeData +=
ExternalIndexerGatheringNodeData;
}
private void ExternalIndexerGatheringNodeData(object sender, IndexingNodeDataEventArgs e)
{
if (e.IndexType == IndexTypes.Content)
{
try
{
var fields = e.Fields;
var combinedFields = new StringBuilder();
foreach (var keyValuePair in fields) //only get your fields here instead of all of them
{
combinedFields.AppendLine(keyValuePair.Value);
}
e.Fields.Add("contents", combinedFields.ToString());
}
catch (Exception ex)
{
LogHelper.Error<Exception>("error munging fields for " + e.NodeId, ex);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment