Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 01D78108EF for ; Sat, 27 Jul 2013 05:39:28 +0000 (UTC) Received: (qmail 52199 invoked by uid 500); 27 Jul 2013 05:39:25 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 51895 invoked by uid 500); 27 Jul 2013 05:39:16 -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 51887 invoked by uid 99); 27 Jul 2013 05:39:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Jul 2013 05:39:15 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of Lisheng.Zhang@broadvision.com designates 139.56.8.26 as permitted sender) Received: from [139.56.8.26] (HELO mail-fw.broadvision.com) (139.56.8.26) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Jul 2013 05:39:10 +0000 X-ASG-Debug-ID: 1374903529-63ee00000000-H1Y1KX X-Barracuda-URL: http://mail-fw.broadvision.com:8000/cgi-bin/mark.cgi Received: from RW-EX2003.BROADVISION.COM (localhost [127.0.0.1]) by mail-fw.broadvision.com (Spam Firewall) with ESMTP id 9AB4A223B03 for ; Fri, 26 Jul 2013 22:38:49 -0700 (PDT) Received: from RW-EX2003.BROADVISION.COM (rw-ex2003.broadvision.com [10.10.32.18]) by mail-fw.broadvision.com with ESMTP id oIUjSlCWuz6c5vCV for ; Fri, 26 Jul 2013 22:38:49 -0700 (PDT) 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 X-ASG-Orig-Subj: RE: Detect a corrupted index Subject: RE: Detect a corrupted index Date: Fri, 26 Jul 2013 22:38:49 -0700 Message-ID: In-Reply-To: <1374892352027-4080747.post@n3.nabble.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Detect a corrupted index Thread-Index: Ac6KcaAAJ3B/aqc7Tgimm//OvFnKGgAGO5WQ From: "Zhang, Lisheng" To: X-Barracuda-Connect: rw-ex2003.broadvision.com[10.10.32.18] X-Barracuda-Start-Time: 1374903529 X-Barracuda-Virus-Scanned: by Barracuda Spam Firewall at broadvision.com X-Virus-Checked: Checked by ClamAV on apache.org Hi, I used in the following code to detect data corruption in lucene 4.3.0: ///////////////////////////////// import org.apache.lucene.index.CheckIndex; ... CheckIndex checkIndex =3D new = CheckIndex(getLuceneDirectory(folderPath)); CheckIndex.Status status =3D checkIndex.checkIndex(); if(!status.clean) { printStatusDetails(status); } private static void printStatusDetails(CheckIndex.Status status) { if(status.toolOutOfDate) { log("Index version and checking tool does not match, checking is = not conclusive"); return; } if(status.missingSegments) { log("Cannot locate and load the segments_N file."); } if(status.missingSegmentVersion) { log("Cannot read version number from segment_N file"); } if(status.cantOpenSegments) { log("Cannot open segment_N file"); } if(status.numBadSegments > 0) { log("There are (" + status.numBadSegments + ") out of (" + = status.numSegments + ") total segments"); } } private static Directory getLuceneDirectory(String path) throws Exception { return FSDirectory.open(new File(path)); } /////////////////////////// Best regards, Lisheng -----Original Message----- From: ABlaise [mailto:ablaise@hotpads.com] Sent: Friday, July 26, 2013 7:33 PM To: java-user@lucene.apache.org Subject: Detect a corrupted index Hi everyone ! So I am working on a Lucene index that will run on a server and since = this server might crash/be killed at any time, even during the creation of an index, I would like to be able to detect if an index is corrupted or = not. I don't care about repairing it, rebuilding it from scratch doesn't take = too long. Any idea or hint on how I should proceed ? I searched for related topics = but they all seemed old and don't apply to Lucene 4.3.1 Thanks in advance Adrien -- View this message in context: = http://lucene.472066.n3.nabble.com/Detect-a-corrupted-index-tp4080747.htm= l Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org