Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 97891 invoked from network); 6 Sep 2006 07:25:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Sep 2006 07:25:32 -0000 Received: (qmail 82679 invoked by uid 500); 6 Sep 2006 07:25:28 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 82296 invoked by uid 500); 6 Sep 2006 07:25:26 -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 82281 invoked by uid 99); 6 Sep 2006 07:25:26 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Sep 2006 00:25:26 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [194.44.23.182] (HELO mail.spline-software.com) (194.44.23.182) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Sep 2006 00:25:24 -0700 Received: by mail.spline-software.com (Postfix, from userid 12) id B46972AA661; Wed, 6 Sep 2006 10:24:58 +0300 (EEST) Received: from [192.168.0.86] (vbychkoviak.jforce [192.168.0.86]) by mail.spline-software.com (Postfix) with ESMTP id A46082AA43F for ; Wed, 6 Sep 2006 10:24:55 +0300 (EEST) Message-ID: <44FE77C7.70700@i-hypergrid.com> Date: Wed, 06 Sep 2006 10:24:55 +0300 From: Volodymyr Bychkoviak User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: java-user@lucene.apache.org Subject: Re: obtaining the number of documents stored in a .cfs file References: <015601c6d0e7$5e42d9a0$a700a8c0@domain.outsystems.com> <1157460488.4933.43.camel@localhost> <44FD76C0.3080303@sirma.bg> In-Reply-To: <44FD76C0.3080303@sirma.bg> Content-Type: multipart/alternative; boundary="------------000504090707010402000605" X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on spline.jforce X-Spam-Level: X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-5.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, HTML_40_50,HTML_MESSAGE autolearn=ham version=3.0.4 X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --------------000504090707010402000605 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I've used following code to recover index. Note: it only works with .cfs files. String path = // path to index File file = new File(path); Directory directory = FSDirectory.getDirectory(file, false); String[] files = file.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".cfs"); } }); SegmentInfos infos = new SegmentInfos(); int counter = 0; for (int i = 0; i < files.length; i++) { String fileName = files[i]; String segmentName = fileName.substring(1, fileName.lastIndexOf('.')); int segmentInt = Integer.parseInt(segmentName,Character.MAX_RADIX); counter = Math.max(counter, segmentInt); segmentName = fileName.substring(0, fileName.lastIndexOf('.')); Directory fileReader = new CompoundFileReader(directory,fileName); IndexInput indexStream = fileReader.openInput(segmentName + ".fdx"); int size = (int)(indexStream.length() / 8); indexStream.close(); fileReader.close(); SegmentInfo segmentInfo = new SegmentInfo(segmentName,size,directory); infos.addElement(segmentInfo); } infos.counter = counter++; infos.write(directory); Stanislav Jordanov wrote: > Suppose I have a bunch of valid .cfs files while the > segmens/segments.new file is missing or invalid. > The task is to 'recover' the present .cfs files into a valid index. > I think it will be necessary and sufficient to create a segments file > that references the .cfs files. > The only problem I've encountered in generating a vaild and > well-formed segments file is that I need to know the number of docs in > each cfs file. > So the couple of questions is: > Do I have to put the right number of docs for each segments or any > (dummy) number will do? > If I have to put the right number there, how do I get it having the > cfs file? > > Stanislav > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > -- regards, Volodymyr Bychkoviak --------------000504090707010402000605--