Home | About | Sematext search-lucene.com search-hadoop.com
 Search Lucene and all its subprojects:

Switch to Plain View
Lucene, mail # user - IndexWriter and Directory create param


+
Leslie Hughes 2003-06-10, 06:14
Copy link to this message
-
Re: IndexWriter and Directory create param
Otis Gospodnetic 2003-06-10, 07:02
Hello Les,

> Directory dir = FSDirectory.getDirectory("myindex", true);
> IndexWriter writer = new IndexWriter(dir, myAnalyser, true);
>
> which gives me a nice clean index. But what if the create params are
> different? If I open a directory with create=false then create a
> writer on it with create = true will this give problems?

If I understand you correctly, then the answer is: no, this should not
cause problems.  You could easily try that, no?

> Maybe I should do something like
>
> boolean flag = true/false;
> Directory dir = FSDirectory.getDirectory("myindex", flag);
> IndexWriter writer = new IndexWriter(dir, myAnalyser, false);

I've seen people use code like that.

> Whilst I'm on the subject, there doesn't appear to be a standard way
> of creating a Directory, FSDir has a getDirectory whilst RAMDir uses
a
> constructor - shouldn't there be a standard method on the Directory
> interface (like there is with close)? Or maybe a configurable
> DirectoryFactory?

Perhaps.  Directory is an abstract class.  One could add an abstract
open(...) method, maybe.  I don't have a need for it...

Otis
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

---------------------------------------------------------------------
+
Leslie Hughes 2003-06-10, 07:17
+
Otis Gospodnetic 2003-06-10, 07:22