Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lucene.Net QueryParser throws an IOException (read past eof)

Tags:

c#

lucene.net

I have the following code, where I pass a search value and an analyzer:

private static Query Query(string searchValue, StandardAnalyzer analyzer)
{
    var queryParser = new QueryParser(Version.LUCENE_30, "Data", analyzer);
    return queryParser.Parse(searchValue);
}

The exception is being thrown in the Parse method.

The results are being returned correctly, so everything works fine; it's just that annoying exception. Am I suppose to ignore it? Is it a default behaviour of Lucene.Net? I'm using version 3.0.3.

Found this post before, however none of the points mentioned in the answer apply. The index is not corrupted - checked in Luke.Net and by Lucene's CheckIndex class. There is no problem with the write permission, as I can write to the index and nothing else is using the index files.

like image 968
Jerry Avatar asked Sep 18 '13 10:09

Jerry


2 Answers

Both Lucene and Lucene.net have been designed with Exceptions that determine control flow of the code. You will see exceptions all over when the debugger symbols run. However, the exceptions should be isolated and handled inside the library. If you have exceptions not being handled and throwing errors in your UI then that is a problem.

I actually removed some exceptions in Lucene in very specific scenarios and gained a huge perf improvement...but I am sure that is not recommended.

like image 112
Bart Czernicki Avatar answered Sep 21 '22 00:09

Bart Czernicki


Lucene.NET (at the time of version 3.0.3) used IOExceptions to manage several parts of the parser's flow. This had a bad impact on the performance (up to 90ms on my development machine).

Good news is that the version currently in their source code repository at http://lucenenet.apache.org/community.html seems to have removed the specific exceptions that were causing this. Certainly for me, this has improved performance a lot. Hope this helps.

like image 31
Peter Avatar answered Sep 20 '22 00:09

Peter