I'm using an EJB to process documents using Lucene 1.3. Things are working fine now, but I wanted to double check that this will work with multiple instances of the EJB. I know this is not conforming to the EJB spec concerning file I/O, but ignoring that for now, my question is about thread safety. From the FAQ I see that IndexWriter and IndexSearcher are thread safe, but QueryParser is not, so I'll have to change that to a singleton.
My use of Lucene is not the typical scenario: A document is converted from it's original format (ex. PDF) using the GATE framework, then the index created, a query parsed, the query run, and the index deleted. So each call to the EJB is acting only on objects/index created during that call. Here are the core steps: Factory.createDataStore("gate.persist.SerialDataStore", datastoreURLStr); [GATE call] indexedCorpus.getIndexManager().createIndex(); [GATE call that uses Lucene under the hood] IndexSearcher search = new IndexSearcher(this.indexedCorpus .getIndexDefinition().getIndexLocation()); luceneQuery = QueryParser.parse(theQuery,"body", new SimpleAnalyzer()); Hits hits = search.search(luceneQuery); Explanation ex = search.explain(luceneQuery, hits.id(0)); deleteDirectory(this.indexSubDir); Factory.deleteResource(this.indexedCorpus); [GATE call] Thanks, Keith