Is it better to reuse or create an analyzer, IndexSearcher, IndexWriter in each call?

I am new to Lucene.net and trying to adapt the search code here , which essentially creates new Analyzer , IndexSearcher and IndexWriter objects in each method, and only the FSDirectory object is reused.

Question: Are there any recommended best practices for reusing these facilities?

The previous results for Lucene.Net optimization are many years ago, and from personal experience the Lucene.Net library has changed: downloading examples and compiling them using 3.0.3 does not work without changing the code.

+4
source share
2 answers

What about BestPractices from the official wiki?

+3
source

In our project, we reuse Analyzer and enter it with a predefined Version in IndexWriter and IndexReader . It is recommended that Analyzer be the same when indexing and when searching, so at least the template is applied to it.

Since the last two are wrappers for actually accessing the Lucene index, you will need to create an index stream every time you use them, and it would make little sense to reuse them since they will block simultaneous calls (both read and write s).

There are several “best practices” and templates in this project that you can use.

+1
source

All Articles