More in this section

Forums / Developing with Sitefinity / AutoIndex CustomIndex

AutoIndex CustomIndex

2 posts, 0 answered
  1. KMac
    KMac avatar
    133 posts
    15 Dec 2008
    20 Jan 2010
    Link to this post

    Quick question. How do I set a customIndex provider to autoindex? I currently have an customIndex that indexes documents in a library and I want it to either reindex after a new item is added or at least at specific time intervals.

    Thanks in advance,

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    20 Jan 2010
    Link to this post
    Hello KMac,

    In the provider class override Initialize. Subscribe for Executed event of ContentManager and run the index if an item is created, updated, deleted

    sample code

    protected virtual void ContentProvider_Executed(object sender, ExecutedEventArgs e)
        switch (e.CommandName)
            case "UpdateContent":
            case "CreateContent":
                IContent content = (IContent)e.Data;
                if (content.Status != ContentStatus.Published)
                    IIndexerInfo[] info;
                    if (this.manager.Provider.AllowLocalization)
                        CultureInfo cult = CultureInfo.GetCultureInfo(content.Language);
                        string path = this.GetItemUrl(content, this.baseUrl, cult);
                        info = new IIndexerInfo[] { this.GetIndexerInfo(path, content, cult) };
                        string path = this.GetItemUrl(content, this.baseUrl, null);
                        info = new IIndexerInfo[] { this.GetIndexerInfo(path, content) };
                    this.OnIndex(new IndexEventArgs(info));
            case "DeleteContent":
                Guid itemId = e.ItemID;
                if (itemId != Guid.Empty)
                    this.OnIndex(new IndexEventArgs("DeleteIndex", new Guid[] { itemId }));

    virtual void OnIndex(IndexEventArgs args)
     if (this.Index != null)
       this.Index(this, args);
     public event EventHandler<IndexEventArgs> Index;

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered