lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Saurabh Gokhale <saurabhgokh...@gmail.com>
Subject Re: Questions on index Writer
Date Sun, 17 Jul 2011 03:03:46 GMT
Thanks guys, that helped a lot.

Saurabh

On Sat, Jul 16, 2011 at 3:08 PM, Mihai Caraman <caraman.mihai@gmail.com>wrote:

> >
> > indexWriter = new IndexWriter(FSDirectory.open(new File(indexDirName)),
> > getAnalyzer(), true, MaxFieldLength.UNLIMITED);
> >
> > Does this statement cleans up existing index files?
>
> yes
>
>
> > If yes, then how do I
> > tackle a scenario where lets say I brought down my application server
> > hosting code to create lucene index and then start it again, this way a
> new
> > JVM will start creating indexWriter instance again which will eventually
> > clean up my existing index files.
> >
>
> indexWriter = new IndexWriter(FSDirectory.open(new File(indexDirName)),
>            getAnalyzer(), *false*, MaxFieldLength.UNLIMITED);
>
> Note:
>  To avoid using deprecated method use the equivalent code:
>
>        Directory idx = new NIOFSDirectory(new File(indexDirName), null);
>        IndexWriterConfig iConfig = new
> IndexWriterConfig(Version.LUCENE_31,getAnalyzer());
>        iConfig.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
>        indexWriter = new IndexWriter(idx, iConfig);
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message