public class BlogSave : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
//Add event to allow searching by site section
LogHelper.Info<BlogSave>("Attatching BlogSaveHandler to ExamineManager.Instance.IndexProviderCollection[\"ExternalIndexer\"].DocumentWriting");
var indexerSite = (UmbracoContentIndexer)ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"];
var helper = new UmbracoHelper(UmbracoContext.Current);
indexerSite.DocumentWriting += (sender,e) => IndexerSite_DocumentWriting(sender, e, helper);
LogHelper.Info<BlogSave>("BlogSaveHandler attached to ExamineManager.Instance.IndexProviderCollection[\"ExternalIndexer\"].DocumentWriting");
}
private void IndexerSite_DocumentWriting(object sender, Examine.LuceneEngine.DocumentWritingEventArgs e, UmbracoHelper helper)
{
var tagsOnNode = helper.TagQuery.GetTagsForEntity(e.NodeId).Where(t => t.Group == "Blog");
LogHelper.Debug<BlogSave>($"Addings tags for node:{e.NodeId} to field:tagList");
foreach (var tag in tagsOnNode)
{
e.Document.Add(new Field("tagList", tag.Text, Field.Store.YES, Field.Index.ANALYZED));
LogHelper.Debug<BlogSave>($"Tag: {tag.Text} for node:{e.NodeId} added to field:tagList");
}
}
}
multi value index / search on tag field
In later versions of lucene you can do multi value fields. Does anyone know how todo this in examine?
Regards
Ismail
Here is an example which we used for the Blog
is working on a reply...