Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 14388 invoked from network); 23 Aug 2006 11:04:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 23 Aug 2006 11:04:09 -0000 Received: (qmail 76800 invoked by uid 500); 23 Aug 2006 11:04:03 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 76764 invoked by uid 500); 23 Aug 2006 11:04:02 -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 76753 invoked by uid 99); 23 Aug 2006 11:04:02 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Aug 2006 04:04:02 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [217.15.245.75] (HELO post01.avanza.se) (217.15.245.75) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Aug 2006 04:04:02 -0700 Received: from ad01.aza.se (ad01.aza.se [172.22.30.200]) by post01.avanza.se (Postfix) with ESMTP id 3D646746C5 for ; Wed, 23 Aug 2006 13:03:40 +0200 (MET DST) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: Problem updating index while reader is open Date: Wed, 23 Aug 2006 13:04:23 +0200 Message-ID: <6F4F5B8F19AA954DB9002305E4D6D14901BD98@ad01.aza.se> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Problem updating index while reader is open Thread-Index: AcbGo8oxewzV3zZCRL2m+y5RPop/1w== From: =?iso-8859-1?Q?Bj=F6rn_Ekengren?= To: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N If I try to add documents to an index while a reader is open I get en = error message saying "Cannot delete C:\myindex\_3n.f0". I suspect that = this is due to the fact that the windows fs won't allow deletion of a = file when there is a filehandler connected to it. The solution I have at = the moment is this: boolean isWindows =3D = System.getProperty("os.name").indexOf("indows")!=3D-1; IndexReader reader =3D = searcher.getIndexSearcher().getIndexReader(); try { if(isWindows) reader.close(); // Need to close reader on windows = since the windows file system won't allow deletion of a file with an = open filehandler IIndexer indexer =3D searcher.getIndexer(); addedDocuments =3D indexer.rebuildIndex(); if(isWindows) searcher.setIndexSearcher(new = IndexSearcher(searcher.getIndexDir()));//restore index searcher } catch (IOException e) { e.printStackTrace(); } However this means that I cannot search the index while updating it (or = in this case rebuilding it completely). Are there any workaround for = this ? Maybe you could rebuild the index into another place on the disk = and when it is finished set the searcher to operate in the new place. = This would lead to that it is not possible to query the new index until = finished. Could you get around this if you build the new index as a = RamDirectory which is flushed to disk when finished ? --regards /Bjorn --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org