Currently I’m working with Lucene 3.6 and am having difficulty getting IndexWriters to work.
The API documents suggest that:
IndexWriter writer = new IndexWriter(Directory, Analyzer);
(and a few other similar constructors)is depreciated and that I should use something like:
IndexWriter writer = new IndexWriter(Directory, Configuration);
However eclipse won’t recognize this newer constructor (lucene-core3.6.jar is added to the build path of my project) and if I use an older constructor I have to suppress a warning (which I don’t especially want to do – an exception gets thrown when I index in memory with these older methods).
I’ve cleaned the project, but the problem still persists.
EDIT: The code I am using:
Directory index = new RAMDirectory();
StandardAnalyzer analyzer = new StandardAnalyzer();
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_36, analyzer);
IndexDeletionPolicy IndexDeletionPolicy = new KeepOnlyLastCommitDeletionPolicy();
MaxFieldLength fieldLength = new MaxFieldLength(256);
IndexWriter writer = new IndexWriter(index, analyzer, false, IndexDeletionPolicy, fieldLength);
//IndexWriter writer = new IndexWriter(index, config);
writer.setUseCompoundFile(false);
I solved the problem:
There was a .jar file interfering with lucene (thirdparty-all.jar) which I found through looking at the stack trace. Removing the .jar removed problem.