Alex Johansson
Alex Johansson

Reputation: 73

Lucene.NET, StandardAnalyzer, stopwords and thread-safety

When the code executes below I assume that the stopwords file is read from the file system every time I parse a query. Instead of doing this, can I reuse the same instance of the analyzer instead of creating a new one? Is it thread-safe? (After much googling I can not find any information on this)

var stopwordsFile = new FileInfo("C:\MyStopWordsFile.txt");
var analyzer = new StandardAnalyzer(stopwordsFile);
var queryParser = new QueryParser("", analyzer);
var query = queryParser.Parse(stringToParse);

Upvotes: 5

Views: 2254

Answers (1)

si618
si618

Reputation: 16848

The docs state that only static instances of StandardAnalyzer are thread safe. QueryParser is the same.

Upvotes: 3

Related Questions