lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: Build RAMDirectory on FSDirectory, and then synchronzing the two
Date Mon, 09 Jan 2012 10:23:11 GMT
If you load an existing disk index into a RAMDirectory, make some
changes in RAM and call addIndexes to add the contents of the
RAMDirectory to the original disk index, you are likely to end up with
duplicate data on disk.  Depending of course on what you've done to
the RAM index.

Sounds you want to call addIndexes using a writer on a new, empty,
index or overwrite the original. IndexWriterConfig.OpenMode CREATE.


--
Ian.


On Mon, Jan 9, 2012 at 4:29 AM, dyzc <1393975679@qq.com> wrote:
> I'd better provide a snapshot of my code for people to understand my issues:
>
>
> File file=new File("c:/index_files");
> FSDirectory fsDir=new FSDirectory(file);
> RAMDirectory ramDir=new RAMDirectory(fsDir, new IndexWriterConfig(Version.LUCENE_35,
new StandardAnalyzer());
>
>
> IndexWriter iw = new IndexWriter(ramDir, iwc);
>
>
> ......DO something here with iw (associated with ramDir).....
>
>
> Now I am trying to synchronize ramDir with fsDir:
>
>
> //close iw prior to synchronization
> iw.close();
>
>
> // synchronize RAM with FS
> IndexWriter writer = new IndexWriter(fsDir,     new IndexWriterConfig(Version.LUCENE_35,
ik));
> writer.addIndexes(ramDir);
> writer.close();
> ramDir.close();
>
>
>
> Now I end up with duplicate copies of index files in c:/index_files
>
>
> Is there something that I miss here?
>
>
> ------------------ Original ------------------
> From:  "zhoucheng2008"<zhoucheng2008@gmail.com>;
> Date:  Mon, Jan 9, 2012 12:04 PM
> To:  "java-user"<java-user@lucene.apache.org>;
>
> Subject:  Build RAMDirectory on FSDirectory, and then synchronzing the two
>
>
> Hi,
>
> I new a RAMDirectory based upon a FSDirectory. After a few modifications, I would like
to synchronize the two.
>
>
> Some on the mailing list provided a solution that uses addIndex() function.
>
>
> However, the FSDirectory simply combines with the RAMDirectory, and the size doubled.
>
>
> How can I do a real synchronization?
>
>
> Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message