You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Shane <lu...@my-family.us> on 2007/02/23 19:53:18 UTC
Determining if index exists Lucene 2.1
Hi,
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?
Thanks,
Shane
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Determining if index exists Lucene 2.1
Posted by Michael McCandless <lu...@mikemccandless.com>.
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
Re: Determining if index exists Lucene 2.1
Posted by karl wettin <ka...@gmail.com>.
23 feb 2007 kl. 19.53 skrev Shane:
>
> Is there a function call to determine whether or not an index
> already exists?
<http://lucene.apache.org/java/docs/api/org/apache/lucene/index/
IndexReader.html#indexExists(org.apache.lucene.store.Directory)>
HTH
--
karl
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org