You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Hoss Man (JIRA)" <ji...@apache.org> on 2006/02/17 20:11:24 UTC
[jira] Commented: (LUCENE-301) Index Writer constructor flags
unclear - and annoying in certain cases
[ http://issues.apache.org/jira/browse/LUCENE-301?page=comments#action_12366834 ]
Hoss Man commented on LUCENE-301:
---------------------------------
>The only change (and I consider it an improvment, and unlikely to break anyones
>code) is that if it is set to false, and no index exists yet, then it will
>create a new empty index at the specified location.
...that could be very bad for tools/apps that wantto update an existing index after reading the directory path from user input or configs when the user makes a typo. In the past "new IndexWriter(d,a,false) would throw an Exception indicating a problem, with the change you describe it would happily make a new index.
I'd be happy to see a more explict API with more options about what you want IndexWRiter to do if/when the directory does'doesn't exist ... but it should be 100% backwards compatible. deprecating this constructor but leaving it alone and adding a new one with more options seems like a much safer approach.
> Index Writer constructor flags unclear - and annoying in certain cases
> ----------------------------------------------------------------------
>
> Key: LUCENE-301
> URL: http://issues.apache.org/jira/browse/LUCENE-301
> Project: Lucene - Java
> Type: Improvement
> Components: Index
> Versions: 1.4
> Environment: Operating System: other
> Platform: Other
> Reporter: Dan Armbrust
> Assignee: Lucene Developers
> Priority: Minor
>
> Wouldn't it make more sense if the constructor for the IndexWriter always
> created an index if it doesn't exist - and the boolean parameter should be
> "clear" (instead of "create")
> So instead of this (from javadoc):
> IndexWriter
> public IndexWriter(Directory d,
> Analyzer a,
> boolean create)
> throws IOException
> 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.
> Parameters:
> d - the index directory
> a - the analyzer to use
> create - true to create the index or overwrite the existing one; false to
> append to the existing index
> Throws:
> IOException - if the directory cannot be read/written to, or if it does not
> exist, and create is false
> We would have this:
> IndexWriter
> public IndexWriter(Directory d,
> Analyzer a,
> boolean clear)
> throws IOException
> Constructs an IndexWriter for the index in d. Text will be analyzed with a.
> If clear is true, and a index exists at location d, then it will be erased, and
> a new, empty index will be created in d.
> Parameters:
> d - the index directory
> a - the analyzer to use
> clear - true to overwrite the existing one; false to append to the existing
> index
> Throws:
> IOException - if the directory cannot be read/written to, or if it does not
> exist.
> Its current behavior is kind of annoying, because I have an app that should
> never clear an existing index, it should always append. So I want create set to
> false. But when I am starting a brand new index, then I have to change the
> create flag to keep it from throwing an exception... I guess for now I will
> have to write code to check if a index actually has content yet, and if it
> doesn't, change the flag on the fly.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org