DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=36242>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=36242 Summary: Creating a new index vs. opening an existing one Product: Lucene Version: 1.4 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P5 Component: Index AssignedTo: java-dev@lucene.apache.org ReportedBy: [EMAIL PROTECTED] Currently I have to tell the IndexWriter constructor whether I want a new index created or not. The behaviour I'd like is to open an index if one exists, or create a new one if it doesn't exist. Now I check for a 'segments' file in my code to make the choice: boolean CreateNew=false; // Create a new index ONLY if one doesn't exist already. Even then, we first try to open // an existing index. if (!(new java.io.File(IndexPath+"\\segments")).exists()) { CreateNew=true; } try { writer = new IndexWriter(IndexPath, new StandardAnalyzer(), false); } catch (IOException e) { if (CreateNew) { writer = new IndexWriter(IndexPath, new StandardAnalyzer(), true); } else { throw e; } } I believe this logic would make more sense inside Lucene. -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]