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 "Eduardo S. Cordeiro" <es...@gmail.com> on 2006/06/14 01:23:47 UTC
Detecting index existance
Hi there,
I'm just starting up with Lucene after reading bits and pieces from
Gospodnetic and Hatcher's "Lucene in Action" (and noticing the API has
changed for 2.0.0).
My question is this: is there a way to detect whether or not the index
exists? I'm currently developing a web application that will use
Lucene for searching, but all indexable data will be entered by admin
users of this webapp, so there is no initial index. My hope is to be
able to create an empty one "on the fly" as it is first needed...is
this possible?
Thanks and regards,
Eduardo Cordeiro
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Detecting index existance
Posted by "Eduardo S. Cordeiro" <es...@gmail.com>.
Hi,
Kent's suggestion worked (in fact, I had looked for such a method in
other classes of the API -- forgot to look in IndexReader).
It works just as expected :)
Thanks again
On 6/13/06, Erick Erickson <er...@gmail.com> wrote:
> Well, I just tried it (opening an IndexSearcher) and got this exception...
>
> java.io.FileNotFoundException: C:\blank\segments (The system cannot find the
> file specified)
>
> The directory c:\blank exists, but is empty. So, it seems you can just catch
> the exception and infer that your admin users aren't doing very well at
> keeping up <G>. Or you could test for the existence of the sebments file
> first, up to you.
>
> Best
> Erick
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Detecting index existance
Posted by Erick Erickson <er...@gmail.com>.
Well, I just tried it (opening an IndexSearcher) and got this exception...
java.io.FileNotFoundException: C:\blank\segments (The system cannot find the
file specified)
The directory c:\blank exists, but is empty. So, it seems you can just catch
the exception and infer that your admin users aren't doing very well at
keeping up <G>. Or you could test for the existence of the sebments file
first, up to you.
Best
Erick