lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Janssen <jans...@parc.com>
Subject Re: lucene-core-2.2.0.jar broken? CorruptIndexException?
Date Wed, 28 Nov 2007 10:22:54 GMT
Here's the code I'm using:

        try {

            // Now add the documents to the index
            IndexWriter writer = new IndexWriter(index_loc, new StandardAnalyzer(), !index_loc.exists());
            writer.setMaxFieldLength(Integer.MAX_VALUE);

            try {
                for (int i = start;  i < ids.length;  i ++) {
                    docit = build_document_iterator(doc_root_dir, ids[i]);
                    int count = 0;
                    while (docit.hasNext()) {
                        writer.addDocument((Document)(docit.next()));
                        count += 1;
                    }
                    System.out.println("Added " + docit.id + " (" + count + " versions)");
                    System.out.flush();
                }
            } finally {
                // And close the index
                System.out.println("Optimizing...");
                writer.optimize();
                writer.close();
            }

        } catch (Exception e) {
	    e.printStackTrace(System.err);
        }

Bill

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message