Umbraco + Examine + Lucene.NET Index Problem

We have an ASP.NET web site that we recently moved from a different CMS to Umbraco 10.6.1 which uses Examine 3.0.1.0 and Lucene.net 4.8.0.0 to do content indexing. We have a couple parts of our site that then use these indexes to do content searches. The problem we are having is that periodically queries to the index will start to fail. Once they start failing every query will fail and will continue to fail until we restart the app pool at which time everything will work fine again for a while. Our most basic query, which takes no user input, looks basically like this:

if (!_examineManager.TryGetIndex(UmbracoIndexes.ExternalIndexName, out var index) || !(index is IUmbracoIndex umbIndex))
            {
                throw new InvalidOperationException($"No index found by name ExternalIndex or is not of type {typeof(IUmbracoIndex)}");
            }
QueryOptions queryOptions = new QueryOptions(0, 3000);
string[] docTypes = docTypeList.ToArray(); // Gets populated with a list of doc types
var resultsAsSearchItems = index
             .Searcher
             .CreateQuery(IndexTypes.Content)
             .Field("__Published_en", "y")
             .And()
             .GroupedOr(new[] { "__NodeTypeAlias" }, docTypes)
             .Execute(queryOptions);

The error we receive looks like this:

System.NullReferenceException: Object reference not set to an instance of an object.
at Lucene.Net.QueryParsers.Classic.ParseException.Initialize(Token currentToken, Int32[][] expectedTokenSequences, String[] tokenImage)
at Lucene.Net.QueryParsers.Classic.QueryParser.GenerateParseException()
at Lucene.Net.QueryParsers.Classic.QueryParser.Jj_consume_token(Int32 kind)
at Lucene.Net.QueryParsers.Classic.QueryParser.Clause(String field)
at Lucene.Net.QueryParsers.Classic.QueryParser.Query(String field)
at Lucene.Net.QueryParsers.Classic.QueryParser.TopLevelQuery(String field)
at Lucene.Net.QueryParsers.Classic.QueryParserBase.Parse(String query)
at Examine.Lucene.Search.LuceneSearchQueryBase.GetFieldInternalQuery(String fieldName, IExamineValue fieldValue, Boolean useQueryParser)
at Examine.Lucene.Search.LuceneSearchQuery.Search(QueryOptions options)

We also have a more complex query that fails with this stack trace:

System.NullReferenceException: Object reference not set to an instance of an object.
at Lucene.Net.QueryParsers.Classic.QueryParser.Jj_add_error_token(Int32 kind, Int32 pos)
at Lucene.Net.QueryParsers.Classic.QueryParser.Jj_scan_token(Int32 kind)
at Lucene.Net.QueryParsers.Classic.QueryParser.Jj_3R_2()
at Lucene.Net.QueryParsers.Classic.QueryParser.Jj_3_1()
at Lucene.Net.QueryParsers.Classic.QueryParser.Jj_2_1(Int32 xla)
at Lucene.Net.QueryParsers.Classic.QueryParser.Clause(String field)
at Lucene.Net.QueryParsers.Classic.QueryParser.Query(String field)
at Lucene.Net.QueryParsers.Classic.QueryParser.TopLevelQuery(String field)
at Lucene.Net.QueryParsers.Classic.QueryParserBase.Parse(String query)
at Examine.Lucene.Search.LuceneSearchQueryBase.GetFieldInternalQuery(String fieldName, IExamineValue fieldValue, Boolean useQueryParser)
at Examine.Lucene.Search.LuceneSearchQuery.Search(QueryOptions options)

There doesn’t seem to be any pattern to when this happens, and we can’t identify an specific things that causes it to start failing.

Leave a Comment