lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roger dimitri <>
Subject backup RAMDirectory to file
Date Thu, 20 Mar 2008 18:47:58 GMT
  I am using the Directory class's copy method to periodically sync my RAM based index to
a file based index that's supposed to serve as a hot backup. I want to know if this is the
right way to maintain a periodic backup of my RAM based index and, if Yes, then is it reliable
in a production instance with almost 12 to 15 GB of Lucene index loaded into the RAMDirectory.

Any advice is greatly appreciated.
I have a sample working code snippet here:

public class RAMtoFILEcopy_test1 {

    static String[] queries = {
        "a OR b AND c",
        "(a OR b) AND c",
        "a OR (b AND c)",
        "a AND b",
        "a AND b OR c AND d",
        "(a AND b) OR (c AND d)",
        "a AND (b OR c) AND d",
        "((a AND b) OR c) AND d",
        "a AND (b OR (c AND d))",
        "a AND b AND c AND d",

        "a OR b AND NOT c",
        "(a OR b) AND NOT c",
        "a OR (b AND NOT c)",
        "a AND NOT d",
        "a AND NOT b OR c AND NOT d",
        "(a AND NOT b) OR (c AND NOT d)",
        "a AND NOT (b OR c) AND NOT d",
        "((a AND NOT b) OR c) AND NOT d",
        "a AND NOT (b OR (c AND NOT d))",
        "a AND NOT b AND NOT c AND NOT d",
    "a OR NOT b",
    "a OR NOT a",

    "a b",
    "a b c",
    "a b (c d e)",
    "+a +b",
    "a -b",
    "a +b -c",
    "+a b -c",
    "+a -b c",
    "a -b -c",
    "-a b c",

    "a OR b c AND d",
    "a OR b c",
    "a AND b c",
    "a OR b c OR d",
    "a OR b c d OR e",
    "a AND b c AND d",
    "a AND b c d AND e"

    public static void main(String argv[]) throws Exception {
        Directory dir = new RAMDirectory();
        Analyzer analyzer = new StandardAnalyzer();
        IndexWriter writer = new IndexWriter(dir, analyzer, true);

        for ( int i=0; i < queries.length; i++ ) {
            Document doc = new Document();
            doc.add(new Field("text", queries[i], Field.Store.YES, Field.Index.TOKENIZED));

        Directory dir2 = FSDirectory.getDirectory("/tmp/TestHotbackup", true);
        dir.copy(dir, dir2, true);



Thanks a lot,

Never miss a thing.  Make Yahoo your home page.
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message