Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 32664 invoked from network); 9 Jul 2005 06:45:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Jul 2005 06:45:09 -0000 Received: (qmail 63623 invoked by uid 500); 9 Jul 2005 06:45:03 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 63602 invoked by uid 500); 9 Jul 2005 06:45:03 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 63589 invoked by uid 99); 9 Jul 2005 06:45:03 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jul 2005 23:45:03 -0700 X-ASF-Spam-Status: No, hits=1.0 required=10.0 tests=RCVD_IN_NJABL_PROXY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [17.250.248.45] (HELO smtpout.mac.com) (17.250.248.45) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jul 2005 23:45:01 -0700 Received: from mac.com (smtpin08-en2 [10.13.10.153]) by smtpout.mac.com (Xserve/8.12.11/smtpout11/MantshX 4.0) with ESMTP id j696ixlv009728 for ; Fri, 8 Jul 2005 23:44:59 -0700 (PDT) Received: from [127.0.0.1] (66-214-154-12.mpk-mres.charterpipeline.net [66.214.154.12]) (authenticated bits=0) by mac.com (Xserve/smtpin08/MantshX 4.0) with ESMTP id j696iwCi002430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 8 Jul 2005 23:44:59 -0700 (PDT) Message-ID: <42CF7269.7000309@mac.com> Date: Fri, 08 Jul 2005 23:44:57 -0700 From: "xing@mac.com" User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: java-user@lucene.apache.org Subject: Loading FS index into RAM index Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I was reading the Lucene book and came across the part where the author detailed how to write index to ram dir and then flush it to file dir. That turned on a light bulb and I want to do bidirectional index loading. Build index in ram, store in file for backup. Then if I have to shutdown the process, I can then ask it to reload the index from file back into ram for searching duties. Unforunately my code below which tries to load fs index into ram fails right at "ram_writer.addIndexes(fs_dir);" with io exception. When I check "/tmp/lucene-index/", which contains a proper index, after the io exception everything was erased and the directory was empty. Thanks for any pointers. Xing try { System.out.println("start"); //IndexWriter file_writer = new IndexWriter("/tmp/lucene-index/", new StandardAnalyzer(), true); IndexWriter ram_writer = new IndexWriter(new RAMDirectory(), new StandardAnalyzer(), true); System.out.println("loaded ram_writer"); Directory[] fs_dir = new Directory[1]; fs_dir[0] = FSDirectory.getDirectory("/tmp/lucene-index/", true); System.out.println("loaded fs_dir"); ram_writer.addIndexes(fs_dir); System.out.println("load fs_dir into ram"); ram_writer.optimize(); System.out.println("optimize ram index"); ram_writer.close(); //index_writer.close(); System.out.println("good"); } catch (IOException ex) { System.out.println("io exception"); } --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org