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???
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
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...
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:
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???
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
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
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...
No. This solution is only a guarantee for you. Every time someone updates or publish in CMS, the index is updated or created
is working on a reply...