Copied to clipboard

Flag this post as spam?

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


  • Ed Bishop 53 posts 203 karma points
    May 19, 2014 @ 15:46
    Ed Bishop
    0

    NodeIndexing doesn't fire on index rebuild

    We have a custom ExamineManager.Instance.IndexProviderCollection["SomeIndexer"].NodeIndexing event handler to exlude certain items from the index. We have noticed that it doesn't fire when you rebuild an index from scratch. 

    Any ideas why this is?

    Cheers,

    Ed

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    May 19, 2014 @ 15:58
    Ismail Mayat
    0

    Ed,

    When you say custom you mean you have created your indexer based on SimpleDataIndexer or you have created your own umbraco index?  Also one thing you do not need gatheringnode data to exclude certain node types you can do it in the examine config file.  

    Regards


    Ismail

  • Ed Bishop 53 posts 203 karma points
    May 19, 2014 @ 16:43
    Ed Bishop
    0

    Hi Ismail,

    It's not exclusion based on a node type it's custom exclusion based on the value of a property in the document.

    This is not a custom indexer, I am simply attaching to the event on our website index, this is a separate index to the umbraco media, member and internal indexes.

    Cheers,

    Ed

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    May 19, 2014 @ 17:02
    Ismail Mayat
    0

    Ed,

    Ok makes sense.  So if definately fires when you publish just one page?  What version of umbraco are you using and can post the code for the event i just want to see how you are doing it.

    Cheers

     

    Ismail

  • Ed Bishop 53 posts 203 karma points
    May 19, 2014 @ 17:10
    Ed Bishop
    0

    Version 6.1.6, upgraded from 4.7.1.1.

        private const string notApprovedFieldKey = "notApproved";

        private void WebIndexer_NodeIndexing(object sender, IndexingNodeEventArgs e)

        {

          bool cancel = false;

          if (string.Compare(e.IndexType, IndexTypes.Content, StringComparison.OrdinalIgnoreCase) == 0)

          {

            if ((!e.Fields.ContainsKey("title") || string.IsNullOrWhiteSpace(e.Fields["title"]))

                || (e.Fields.ContainsKey("umbracoNaviHide") && string.Compare(e.Fields["umbracoNaviHide"], "1", StringComparison.OrdinalIgnoreCase) == 0)

                || (e.Fields.ContainsKey("template") && string.Compare(e.Fields["template"], "0", StringComparison.OrdinalIgnoreCase) == 0))

            {

              cancel = true;

            }

            else

            {

              if (e.Fields.ContainsKey(notApprovedFieldKey) && string.Compare(e.Fields[notApprovedFieldKey], "1", StringComparison.OrdinalIgnoreCase) == 0)

              {

                cancel = true;

              }

              else

              {

                if (e.Fields.ContainsKey(parentIdFieldKey) && string.Compare(e.Fields[parentIdFieldKey], "-1", StringComparison.OrdinalIgnoreCase) != 0)

                {

                  cancel = IsParentNotApproved(e.Fields[parentIdFieldKey]);

                }

              }

            }

          }

          e.Cancel = cancel;

        }

     

     

    Cheers,

    Ed

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    May 21, 2014 @ 10:10
    Ismail Mayat
    1

    Ed,

    Which base class are you inheriting from?

    Regards

    Ismail

  • Ed Bishop 53 posts 203 karma points
    May 21, 2014 @ 13:45
    Ed Bishop
    0

    Ismail,

    umbraco.BusinessLogic.ApplicationBase

    I am aware that this is obsolete in the latest version of Umbraco but we haven't had a chance to upgrade it yet.

    Cheers,

    Ed

  • Ed Bishop 53 posts 203 karma points
    May 23, 2014 @ 12:32
    Ed Bishop
    100

    Thanks to the question from Ismail, I looked into the event ordering in 6.1.6.

    I believe this is caused by the fact that we need to update our code to implement IApplicationEventHandler and hook into the initialise event to register the node indexing handlers early enough in the startup chain.

    Cheers,

    Ed

Please Sign in or register to post replies

Write your reply to:

Draft