lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: Determining if index exists Lucene 2.1
Date Fri, 23 Feb 2007 18:58:29 GMT
Shane wrote:

> Prior to Lucene 2.1, I was using FSDirectory.getDirectory(String path, 
> boolean create)|| inside of a try block to determine whether or not a 
> directory existed.
> 
> With the deprecation of the above class call in Lucene 2.1,  I need a 
> new method for determining the existence of an index.  I can just check 
> to see if either of the files INDEX_PATH/segments or 
> INDEX_PATH/segments.gen exist, but that doesn't seem like the best route.
> 
> Is there a function call to determine whether or not an index already 
> exists?

You want IndexReader.indexExists(...).

Also you may want to use the new constructors to IndexWriter that create
a new index if there isn't one already, else open the existing one.

Mike

---------------------------------------------------------------------
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