Created
October 30, 2019 09:07
-
-
Save ismailmayat/560e9a722d6347c5dbb1711902228383 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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