Greenhorn
Greenhorn

Reputation: 1821

Migrating from lucene 2.x to 3.x

I am porting my app from lucene 2.X to lucene 3.X. The following is my issue.

This one was valid in 2.X, but 3.5 throws me an error.

IndexReader reader = IndexReader.open("/home/path/to/my/dataDir");

2.X accepted a string, but 3.5 strictly wants a Directory object. I find Directory to be abstract and the only way to instantiate it seems a RAMDirectory().

How do I go about this and how do I point my reader to the desired directory?

Upvotes: 2

Views: 366

Answers (2)

amas
amas

Reputation: 604

Try to use DirectoryReader.open(FSDirectory .open(new File(indexFilePath))) as IndexReader.open method is deprecated for lucene 4 :)

Upvotes: 3

Greenhorn
Greenhorn

Reputation: 1821

I was able to do it. I just did it this way

IndexReader reader = IndexReader.open(new SimpleFSDirectory(new File("my/desired/path")));`

Thanks for your time.

Upvotes: 0

Related Questions