DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26196>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26196 IndexWriter problem when create set to false ------- Additional Comments From [EMAIL PROTECTED] 2004-03-04 18:47 ------- I'll gladly add some bits here for you Lucene experts to consider. If you chose to use it, then great otherwise that's fine, I just wanted to offer you my two pennies worth :) JavaDoc changes to explain the 'create' field: ------------------------------------------------------------------------------ Constructs an IndexWriter for the index in d. Text will be analyzed with a. If create is true, then a new, empty index will be created in d, replacing the index already there, if any. If create is false, then the existing files will be used. Throws FileNotFoundException if the directory does not exist, or if create is false and the files do not exist. ------------------------------------------------------------------------------ Doug, the suggestions you've made look great to me. Obviously the JavaDocs would need to explain the difference between these new constructors and the current ones. Alternatively, depricate the current constructors and create three new ones with a constant as the third value. The constant could be an internal static class with the three current options. This way you're leaving yourself in a good possition to expand upon these options if the need arrises in the future. E.g. /** [EMAIL PROTECTED] please use IndexWriter( String, Analyzer, CreateOption ) instead. */ public IndexWriter( String path, Analyzer a, boolean create ) { this( path, a, (create ? CREATE_DATA_FROM_SCRATCH : USE_CURRENT_DATA) ); } /** JavaDocs to explain */ public IndexWriter( String path, Analyzer a, CreateOption createOption ) { createOption.runRules(); .. rest of work .... } /** JavaDocs to explain further */ public static final CreateOption CREATE_DATA_FROM_SCRATCH = new CreateOptions( 1 ); /** JavaDocs to explain further */ public static final CreateOption USE_CURRENT_DATA = new CreateOptions( 2 ); /** JavaDocs to explain further */ public static final CreateOption USE_CURRENT_OR_CREATE = new CreateOptions( 3 ); // internal class public static class CreateOption { private int option; public CreateOption( int option ) { this.option = option; } public void runRules() throws IOException { switch( option ) { case 1 : // if the directory doesn't exist, create it // if the files are there, delete them and start again break; case 2 : // if the directory doesn't exist, or the files are not // there, throw a FileNotFoundException, else work with // what's there break; case 3 : // If directry doesn't exist, throw FileNotFoundException // If files don't exist, then create new files, // otherwise use existing break; default : throw new IOException( "Create option not known." ); } } } Please note : I have not compiled this source. I hope this is of some use to you guys ;-) Regards, Nick. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]