+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Custom search index is not updating

Custom search index is not updating

26 posts, 0 answered
  1. Joe Lee
    Joe Lee avatar
    4 posts
    Registered:
    15 Mar 2010
    08 Jun 2010
    Link to this post
    Hi,

        In our wiki site, we have 2 indexing service, a search index from WikiIndex (out of the box with sitefinity) and a custom search index (it's a indexing service that only index a particular wiki library).

        Whenever we create/edit a wiki page, the default search index has updated immediately but the custom search index is never update.

        Could anyone please advice how could we make the custom search index auto updating (scheduled?) ? Or are we missing some setting / coding to make the update indexing service fire after every save action?

    Best Regards,
    Joe
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Jun 2010
    Link to this post
    Hi Joe Lee,

    If your custom provider inherits from ContentIndexProvider then the index should be updated. There is a virtual method ContentProvider_Executed which is called when a new item is added, deleted or updated. Otherwise you need to implement logic that triggers the index when you update, delete, create a content item

    sample code.

    switch (e.CommandName)
    {
        case "UpdateContent":
        case "CreateContent":
        case "DeleteContent":
           // update the whole index not partially
           Telerik.Search.Engine.IndexingService service =
           new Telerik.Search.Engine.IndexingService(indexServiceInfo);
           int timeout = this.Context.Server.ScriptTimeout;
           this.Context.Server.ScriptTimeout = 4800;
           service.Index(false);
           break;
     }

    You can event subscribe in global.asax, Appication_Start for Content.Manager.Executed event from where you could check the CommandName of the content item that is being updated.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. gopalraman gopal
    gopalraman gopal avatar
    52 posts
    Registered:
    03 Dec 2009
    05 Aug 2010
    Link to this post
    hi

    Here i am trying to add Auto Indexing for Forum in Sitefinity 3.7.

    I added the following code by downloading the CustomIndex class files from the given bellow path

    http://www.sitefinity.com/ClientsFiles/089856_CustomIndex.zip now the index occurs only when we click on Start Index link in Administration Tab.

    After adding any post, auto index does not appear.  Can you give the proper file and path to update.


    Thanks
    G.GopalRaman
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    06 Aug 2010
    Link to this post
    Hello gopalraman gopal,

    Forums module does not have events such as "UpdateContent", "DeleteContent" and CreateContent. This means that you have to update the index as my code above shows or create custom events for Forums module that can be used when you update, delete or crete content.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    24 Sep 2010
    Link to this post
    Hi Ivan,

    In my custom module I have a definition of Executed event.
    Could you please explain how to attach ContentProvider_Executed to the event of my custom module?

    Thanks,
    Anton.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    26 Sep 2010
    Link to this post
    Hi Anton,

    If your IndexProvider inherits from ContentIndexProvider the events that trigger the index should be automatically handled by our code. If your index is not based on IContent objects you cannot use ContentManager.Executed event, because the expected objects will be different.

    You can subscribe for the event as shown below

    ((IEventExecute)this.manager.Provider).Executed += new EventHandler<ExecutedEventArgs>(ContentProvider_Executed);


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    06 Dec 2010
    Link to this post
    We have a problem where the index is set to auto update, but the problem is that some news articles are showing up in the results, but when you click on them you get a 404 not found error.

    We've checked, the article still exists.

    What could be the problem here?

    Jacques
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    06 Dec 2010
    Link to this post
    Hi J.Hoventer,

    Possible reasons.

    1. The content item ( title) has been updated and in this case the index is triggered only partially.  Try running the entire index to see if the problem persists.

    2. You are using some web farm scenario and the items are not properly updated. Recently I noticed some issues with such a configuration and we have to investigate this.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    06 Dec 2010
    Link to this post
    1. It's a news item
    2. It's not a web farm
    3. What do you mean the "index is triggered only partially"? Does this mean the client will have to manually update the index each time they write an article? So the marketing team will have to notify the IT team every time?

  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    06 Dec 2010
    Link to this post
    Hello J.Hoventer,

    Here is how the index works

    1. When you create a new item it is added to the index and you should see it in the search results.
    2. When you delete an item it is removed from the index and you should not see it into the search results.
    3. When you update an item it is added to the index, but the "old" item is not removed from the index until you reindex the entire website. This  reason for that is improving performance when you update an item.

    You might find this discussion useful.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    08 Dec 2010
    Link to this post
    In one of the responses you say: "You can event subscribe in global.asax, Appication_Start for Content.Manager.Executed event from where you could check the CommandName of the content item that is being updated."

    Do you have any further documentation on this? I can't see how to subscribe to the Content.Manager.Executed event... not sure which assembly it's part of?
    At application_start is the Content Manager object initiated?

    Regards,
    Jacques
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Dec 2010
    Link to this post
    Hi J.Hoventer,

    Here is  a sample code

    void Application_Start(object sender, EventArgs e)
        {
     
            Telerik.Cms.Engine.ContentManager.Executed += new EventHandler<Telerik.ExecutedEventArgs>(ContentManager_Executed);
     
        }


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    08 Dec 2010
    Link to this post
    Thanks Ivan.

    Would I have been able to find that in any documentation somewhere? I'm battling to understand assembly, using, references etc. so I'm trying to get more documentation to read up.

    It worked. In App_start I subscribed to the event and it's firing now.

    Would I be using your code:
    1.// update the whole index not partially
    2.Telerik.Search.Engine.IndexingService service =
    3.new Telerik.Search.Engine.IndexingService(indexServiceInfo);
    4.int timeout = this.Context.Server.ScriptTimeout;
    5.this.Context.Server.ScriptTimeout = 4800;
    6.service.Index(false);
    7.break;

    Does this run the 'entire' index again or is there a way to confine the task to the news indexing only?

    Regards,
    Jacques
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Dec 2010
    Link to this post
    Hello J.Hoventer,

    This code will run the entire index and its comments shows. You can run partially the index when you update an item following suggestions in this post.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    08 Dec 2010
    Link to this post
    Hi Ivan,

    The context for the URL you're referencing seems different. That seems to be a custom control. I'm just looking to update the index for news items, because when you change the news item name it results in a 404 error.

    So far I have this:
    void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
     
        Telerik.Cms.Engine.ContentManager.Executed += new EventHandler<Telerik.ExecutedEventArgs>(ContentManager_Executed);
    }
     
    void ContentManager_Executed(object sender, Telerik.ExecutedEventArgs e)
    {
        switch (e.CommandName)
        {
            case "UpdateContent":
                // update the whole index not partially
                Telerik.Search.Engine.IndexingService service =
                new Telerik.Search.Engine.IndexingService(indexServiceInfo);
                int timeout = this.Context.Server.ScriptTimeout;
                this.Context.Server.ScriptTimeout = 4800;
                service.Index(false);
                break;
            default:
                break;
        }
    }

    It won't compile though because indexServiceInfo is not a valid object. Where do I get a reference to that object?
  16. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Dec 2010
    Link to this post
    Hi J.Hoventer,

    Inside IndexingService you should pass the index that you want to trigger as a parameter

    IndexDataManager dataManager = new IndexDataManager(); 
    IList indexes = dataManager.GetServices();
    var index = indexes[0];


     
    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  17. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    08 Dec 2010
    Link to this post
    Hi Ivan,

    Sorry to sound ignorant, but I'm not familiar with your assemblies and full API, so the following:
    IndexDataManager dataManager = new IndexDataManager();
    IList indexes = dataManager.GetServices();
    var index = indexes[0];
    Doesn't make much sense to me.

    Do you have documentation that I can read up on for this particular stuff?

    The IndexingService constructor expects an object of type Telerik.Framework.Search.IIndexingServiceInfo which is an interface. The code above that you said I should use has a var and an IList.... I'm not sure what it's supposed to be doing, or how it fits together.

    Regards,
    Jacques
  18. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    09 Dec 2010
    Link to this post
    Hi Ivan,

    I've tried a number of options, but nothing is working, can you look at my previous post and give me some guidance?

    Thanks
    Jacques
  19. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Dec 2010
    Link to this post
    Hi J.Hoventer,

    Below is a sample fully working code with some description in it

    Telerik.Search.Data.IndexingServiceInfo indexServiceInfo = null;
    Telerik.Search.IndexDataManager dataManager = new Telerik.Search.IndexDataManager();
    // retunrs list of all index services that you have created in Sitefinity
    // this returns a list of IndexingServiceInfo item.s
    IList indexes = dataManager.GetServices();
    foreach (Telerik.Search.Data.IndexingServiceInfo ind in indexes)
    {
        if (ind.Name == "news")
        {
            indexServiceInfo = ind;
            break;
        }
    }
    // trigger the entire index service and passing the IndexingServiceInfo
    if (indexServiceInfo != null)
    {
        Telerik.Search.Engine.IndexingService service =
    new Telerik.Search.Engine.IndexingService(indexServiceInfo);
        int timeout = this.Context.Server.ScriptTimeout;
        this.Context.Server.ScriptTimeout = 4800;
        service.Index(false);
        this.Context.Server.ScriptTimeout = timeout;
    }


    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  20. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    09 Dec 2010
    Link to this post
    Hi Ivan,

    I've implemented this approach and it works, but I have to point out the obvious here....

    This is a fundamental flaw in Sitefinity's search and indexing capability.
    I timed how long the re-index would take on this particular site and it was 72 seconds on my local machine. If this was done on a server with loads of traffic being processed it could be a lot worse.
    This means that if the content editor had 20 new news items to load up she would have to wait over one minute after clicking save for each of those items. On more content intensive sites... this would just not be acceptable. You can see how any company investing in a CMS system will think this approach to be extremely poor performance, especially at the new price tag of $8000.

    Is this going to be fixed in version 4?

    We will be deploying the solution today and notifying the customer that it is a Sitefinity flaw/bug and hopefully they will accept it. Not like they have much choice, because there doesn't seem to be a better way to do this. At least not one that you suggested.

    Regards,
    Jacques
  21. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Dec 2010
    Link to this post
    Hello J.Hoventer,

    This is why we do not trigger the entire index when you update a content, but this code will do it and I suggest implementing updating an index base on suggestions provided  in this post -ContentIndexProvider for a custom content module

    Search implementation in Sitefinity 4.0 is still in progress and we will consider such cases.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  22. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    09 Dec 2010
    Link to this post
    Hi Ivan,

    I'm not getting any responses on the other thread.

    The other thread you're referencing is the person building a custom content index provider. All we're trying to do is get the News index provider, or indexing service (whichever it may be), to delete the stale record in it's index when updating a news article.

    Can you provide a code sample of how to do this?

    Thanks,
    Jacques
  23. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 Dec 2010
    Link to this post
    Hi J.Hoventer,

    You need a custom provider if you want to break the default behavior. You need a custom index that inherits from NewsIndexProvider. Inside your custom index you have to override ContentProvider_Executed

    protected override void ContentProvider_Executed(object sender, Telerik.ExecutedEventArgs e)
           {
               base.ContentProvider_Executed(sender, e);
     
               // remove the item
               if (e.CommandName == "UpdateContent")
               {
                   Guid itemId = e.ItemID;
                   if (itemId != Guid.Empty)
                       this.OnIndex(new IndexEventArgs("DeleteIndex", new Guid[] { itemId }));
     
                   // add it again
              
                   IContent content = (IContent)e.Data;
                   IIndexerInfo[] info;
                   string path = this.GetItemUrl(content, this.baseUrl, null);
                   info = new IIndexerInfo[] { this.GetIndexerInfo(path, content) };
                   this.OnIndex(new IndexEventArgs(info)); 
               }
           }

    The provider should be registered in the web.config

    <addname="NewsIndexProviderCustom"type="NewsIndexProviderCustom, App_Code"settingsControl="Telerik.News.WebControls.Search.NewsIndexSettingsControl, Telerik.News"viewSettingsControl="Telerik.News.WebControls.Search.NewsIndexViewControl, Telerik.News"description="Provides not automatic indexing services for News"/>


    Here is another issue. The default news module relies on a specific type for the index provider which is NewsIndexProvider, so you need to crate a custom module that inherits from News


    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  24. Michael Raynal
    Michael Raynal avatar
    9 posts
    Registered:
    18 Nov 2008
    25 Jan 2011
    Link to this post

    Should I expect the IndexingService class to update the last Index date and counts using the code above. The indexing service works and I just ran in today 1/25 but the dates do not change.

    Index status

    • Indexed words: 716
    • Indexed pages: 8
    • Last indexing date: 21 Jan 2011, 12:49
  25. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Jan 2011
    Link to this post
    Hello,

    The last index data should update with the code above. I have just test it on my local project.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  26. Michael Raynal
    Michael Raynal avatar
    9 posts
    Registered:
    18 Nov 2008
    01 Feb 2011
    Link to this post

    My apologizes I should have been more clear. Yes the Indexing service works..however when I publish to my developement or acceptance servers It did not work but appeared too work as no execption was thrown. Combing the IIS logs I found the client credentials were not passed. I added the a line of code (below) to set the system credientials in the client it works fine.

    client.Credentials = System.Net.
    CredentialCache.DefaultCredentials;

     

     

     

Register for webinar
26 posts, 0 answered