Copied to clipboard

Flag this post as spam?

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


  • Kevin C. Halpin 27 posts 108 karma points
    Aug 14, 2018 @ 15:06
    Kevin C. Halpin
    0

    Lucene.Net.Store.AlreadyClosedException: this IndexReader is closed

    Hi all,

    When I add more content through CMS and then try to get that content through an API using Examine I sometimes get this exception: Lucene.Net.Store.AlreadyClosedException: this IndexReader is closed

    I found this link https://github.com/Shazwazza/Examine/issues/23 and I also found that this is fixed in Lucene v3.0 but because of the breaking changes this fix is not compatible with Umbraco v7. I already tried rebuilding the index on publish and save events but that didn't help.

    Here is my code:

    var Searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
        var searchCriteria = Searcher.CreateSearchCriteria();
        var query = searchCriteria.Field("nodeTypeAlias", nodeTypeAlias);
        if (keyword != "")
        {
            query.And().GroupedOr(new string[] { "title", "description" }, keyword);
        }
    
        if (categories != "")
        {
            query.And().GroupedOr(new string[] { "categories" }, categories.Split(','));
        }
    
        if (tags != "")
        {
            query.And().GroupedOr(new string[] { "tags" }, tags.Split(','));
        }
    
        return Searcher.Search(query.Compile());
    

    So, is there some kind of workaround, maybe install older version of Lucene, add something to my code or should I just stop using Examine and do the filtering other way???

  • Kevin C. Halpin 27 posts 108 karma points
    Aug 14, 2018 @ 15:08
    Kevin C. Halpin
    0

    Also I would like to add that when this happens I rebuild the indexes through the CMS (Developer -> Examine Manager) and everything works fine again. I just need to find a way to do this automatically

  • Marcio Goularte 389 posts 1362 karma points
    Aug 14, 2018 @ 16:56
    Marcio Goularte
    0

    Hi, You can implement a recurring task based on that example of that link.

    https://www.isaksen.org/2017/06/22/scheduled-task-in-umbraco-7/

    I did something so where from hour to hour the examine is reindexed. Unfortunately I do not have the example here, but I can post it later

  • Kevin C. Halpin 27 posts 108 karma points
    Aug 14, 2018 @ 19:07
    Kevin C. Halpin
    0

    Hi Marcio, thanks for the answer.

    This is a solution yes, but still not enough. What If someone updates the content through CMS, the index breaks and I have to wait a whole hour for the index to be rebuild? That means that my website would be down all that time...

  • Marcio Goularte 389 posts 1362 karma points
    Aug 15, 2018 @ 16:55
    Marcio Goularte
    0

    No. This solution is only a guarantee for you. Every time someone updates or publish in CMS, the index is updated or created

  • 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