Reputation: 73
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
Reputation: 16848
The docs state that only static instances of StandardAnalyzer are thread safe. QueryParser is the same.
Upvotes: 3