Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Dec 15, 2017 @ 12:44
    Ismail Mayat
    0

    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

  • Damiaan 442 posts 1302 karma points MVP 6x c-trib
    Dec 15, 2017 @ 12:45
    Damiaan
    101

    Here is an example which we used for the Blog

    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");
            }
        }
    }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies