Is there a recommended IndexSearcher method?
A constructor that accepts a directory and an index path internally uses a constructor that uses an IndexReader. Thus, there is no performance advantage of one over the other. Be aware that if you create a finder using IndexReader, you must close it explicitly after closing the finder.
a source to share
It's all about convenience.
If you just want to create IndexSearcher
, use the one that accepts a path.
If you already have an object Directory
, use the one that accepts Directory
.
And if you have IndexReader
... you get the point. Just remember that if you have provided IndexReader
, you must close it yourself after you closed IndexSearcher
.
I highly recommend grabbing a copy of the Lucene source code . It is very readable and can answer many of these questions.
a source to share