Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

indexWriter

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


e.j.w.vanbloem at student

Feb 2, 2007, 7:38 AM

Post #1 of 13 (999 views)
Permalink
indexWriter

Hello,

Does anyone know why this does not work?
The fileDir is of the class File and points to an empty temp directory.
I tried switching true and false


import org.apache.lucene.index.IndexWriter;

File indexDir = new File("c:\temp");

IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(), false);


Regards,

Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org


meils2003 at yahoo

Feb 2, 2007, 7:45 AM

Post #2 of 13 (969 views)
Permalink
RE : indexWriter [In reply to]

Hi Erik

The \ must be escaped in the path, i.e : ...new File("c:\\temp");

Regards,
Olivier

e.j.w.vanbloem[at]student.utwente.nl a écrit : Hello,

Does anyone know why this does not work?
The fileDir is of the class File and points to an empty temp directory.
I tried switching true and false


import org.apache.lucene.index.IndexWriter;

File indexDir = new File("c:\temp");

IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(), false);


Regards,

Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org




---------------------------------
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.


e.j.w.vanbloem at student

Feb 2, 2007, 7:59 AM

Post #3 of 13 (959 views)
Permalink
RE: RE : indexWriter [In reply to]

I already tried that but does not help
do I also have to create a file in that dir? Or is it some other problem

import org.apache.lucene.index.IndexWriter;

File indexDir = new File("c:\\temp");

IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(), false);

________________________________

Van: Virlouvet Olivier [mailto:meils2003[at]yahoo.fr]
Verzonden: vr 2-2-2007 16:45
Aan: java-user[at]lucene.apache.org
Onderwerp: RE : indexWriter



Hi Erik

The \ must be escaped in the path, i.e : ...new File("c:\\temp");

Regards,
Olivier

e.j.w.vanbloem[at]student.utwente.nl a écrit : Hello,

Does anyone know why this does not work?
The fileDir is of the class File and points to an empty temp directory.
I tried switching true and false


import org.apache.lucene.index.IndexWriter;

File indexDir = new File("c:\temp");

IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(), false);


Regards,

Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org




---------------------------------
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org


nileshbansal at gmail

Feb 2, 2007, 8:07 AM

Post #4 of 13 (961 views)
Permalink
Re: RE : indexWriter [In reply to]

Hi,

You first need to initialize the directory (since it's empty).
use,
IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(), true);
the first time you are writing.

-Nilesh

On 2/2/07, e.j.w.vanbloem[at]student.utwente.nl
<e.j.w.vanbloem[at]student.utwente.nl> wrote:
> I already tried that but does not help
> do I also have to create a file in that dir? Or is it some other problem
>
> import org.apache.lucene.index.IndexWriter;
>
> File indexDir = new File("c:\\temp");
>
> IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(), false);
>
> ________________________________
>
> Van: Virlouvet Olivier [mailto:meils2003[at]yahoo.fr]
> Verzonden: vr 2-2-2007 16:45
> Aan: java-user[at]lucene.apache.org
> Onderwerp: RE : indexWriter
>
>
>
> Hi Erik
>
> The \ must be escaped in the path, i.e : ...new File("c:\\temp");
>
> Regards,
> Olivier
>
> e.j.w.vanbloem[at]student.utwente.nl a écrit : Hello,
>
> Does anyone know why this does not work?
> The fileDir is of the class File and points to an empty temp directory.
> I tried switching true and false
>
>
> import org.apache.lucene.index.IndexWriter;
>
> File indexDir = new File("c:\temp");
>
> IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(), false);
>
>
> Regards,
>
> Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>
>
>
> ---------------------------------
> Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>


--
Nilesh Bansal.
http://queens.db.toronto.edu/~nilesh/


rohit.lodha at activesensing

Feb 2, 2007, 8:08 AM

Post #5 of 13 (963 views)
Permalink
Re: indexWriter [In reply to]

flush or close the writer to create the files in the dir.

Rohit

On 2/2/07, e.j.w.vanbloem[at]student.utwente.nl <
e.j.w.vanbloem[at]student.utwente.nl> wrote:
>
> Hello,
>
> Does anyone know why this does not work?
> The fileDir is of the class File and points to an empty temp directory.
> I tried switching true and false
>
>
> import org.apache.lucene.index.IndexWriter;
>
> File indexDir = new File("c:\temp");
>
> IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(),
> false);
>
>
> Regards,
>
> Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>


e.j.w.vanbloem at student

Feb 2, 2007, 8:15 AM

Post #6 of 13 (962 views)
Permalink
RE: RE : indexWriter [In reply to]

got it, thanx


________________________________

Van: e.j.w.vanbloem[at]student.utwente.nl [mailto:e.j.w.vanbloem[at]student.utwente.nl]
Verzonden: vr 2-2-2007 16:59
Aan: "<java-user"@lucene.apache.org
Onderwerp: RE: RE : indexWriter



I already tried that but does not help
do I also have to create a file in that dir? Or is it some other problem

import org.apache.lucene.index.IndexWriter;

File indexDir = new File("c:\\temp");

IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(), false);

________________________________

Van: Virlouvet Olivier [mailto:meils2003[at]yahoo.fr]
Verzonden: vr 2-2-2007 16:45
Aan: java-user[at]lucene.apache.org
Onderwerp: RE : indexWriter



Hi Erik

The \ must be escaped in the path, i.e : ...new File("c:\\temp");

Regards,
Olivier

e.j.w.vanbloem[at]student.utwente.nl a écrit : Hello,

Does anyone know why this does not work?
The fileDir is of the class File and points to an empty temp directory.
I tried switching true and false


import org.apache.lucene.index.IndexWriter;

File indexDir = new File("c:\temp");

IndexWriter writer = new IndexWriter(indexDir, new StandardAnalyzer(), false);


Regards,

Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org




---------------------------------
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org


emailgane at yahoo

Jul 1, 2009, 3:39 AM

Post #7 of 13 (609 views)
Permalink
Re: IndexWriter [In reply to]

Yes. Single IndexWriter could be maintained in a App and it could be closed when the App is shutdown.

Regards
Ganesh

----- Original Message -----
From: "Amin Mohammed-Coleman" <aminmc[at]gmail.com>
To: <java-user[at]lucene.apache.org>
Sent: Wednesday, July 01, 2009 1:27 PM
Subject: IndexWriter


> Hi
>
> This question has probably been asked before so apologies for asking it
> again. Just to confirm that it is ok to use a single index writer in a web
> application and only close that single instance on application shutdown? As
> the indexwriter is thread safe there is no need for any external
> synchronisation. Am I correct in thinking this?
>
> I have configured via spring a single index writer which is used in the
> application and I use the same one for adding and updating documents. This
> index writer is closed when the spring application context shutsdown.
>
>
> Cheers
> Amin
>
Send instant messages to your online friends http://in.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org


simon.willnauer at googlemail

Jul 1, 2009, 3:47 AM

Post #8 of 13 (609 views)
Permalink
Re: IndexWriter [In reply to]

You might want to take care of the write.lock file in the index
directory if your application breaks down. If you do not close the
writer and restart you app you might get an LockObtainFailedException.

simon

On Wed, Jul 1, 2009 at 12:39 PM, Ganesh<emailgane[at]yahoo.co.in> wrote:
> Yes. Single IndexWriter could be maintained in a App and it could be closed when the App is shutdown.
>
> Regards
> Ganesh
>
> ----- Original Message -----
> From: "Amin Mohammed-Coleman" <aminmc[at]gmail.com>
> To: <java-user[at]lucene.apache.org>
> Sent: Wednesday, July 01, 2009 1:27 PM
> Subject: IndexWriter
>
>
>> Hi
>>
>> This question has probably been asked before so apologies for asking it
>> again.  Just to confirm that it is ok to use a single index writer in a web
>> application and only close that single instance on application shutdown?  As
>> the indexwriter is thread safe there is no need for any external
>> synchronisation.  Am I correct in thinking this?
>>
>> I have configured via spring a single index writer which is used in the
>> application and I use the same one for adding and updating documents.  This
>> index writer is closed when the spring application context shutsdown.
>>
>>
>> Cheers
>> Amin
>>
> Send instant messages to your online friends http://in.messenger.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org


aminmc at gmail

Jul 1, 2009, 5:09 AM

Post #9 of 13 (603 views)
Permalink
Re: IndexWriter [In reply to]

Hi all

Thanks for your response. I guess when I add or update using the
indexwriter I need to do the following:

}finally {
if (IndexReader.isLocked(directory)) {
IndexReader.unlock(directory);
}
}


Cheers
Amin



On Wed, Jul 1, 2009 at 11:47 AM, Simon Willnauer <
simon.willnauer[at]googlemail.com> wrote:

> You might want to take care of the write.lock file in the index
> directory if your application breaks down. If you do not close the
> writer and restart you app you might get an LockObtainFailedException.
>
> simon
>
> On Wed, Jul 1, 2009 at 12:39 PM, Ganesh<emailgane[at]yahoo.co.in> wrote:
> > Yes. Single IndexWriter could be maintained in a App and it could be
> closed when the App is shutdown.
> >
> > Regards
> > Ganesh
> >
> > ----- Original Message -----
> > From: "Amin Mohammed-Coleman" <aminmc[at]gmail.com>
> > To: <java-user[at]lucene.apache.org>
> > Sent: Wednesday, July 01, 2009 1:27 PM
> > Subject: IndexWriter
> >
> >
> >> Hi
> >>
> >> This question has probably been asked before so apologies for asking it
> >> again. Just to confirm that it is ok to use a single index writer in a
> web
> >> application and only close that single instance on application shutdown?
> As
> >> the indexwriter is thread safe there is no need for any external
> >> synchronisation. Am I correct in thinking this?
> >>
> >> I have configured via spring a single index writer which is used in the
> >> application and I use the same one for adding and updating documents.
> This
> >> index writer is closed when the spring application context shutsdown.
> >>
> >>
> >> Cheers
> >> Amin
> >>
> > Send instant messages to your online friends
> http://in.messenger.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> > For additional commands, e-mail: java-user-help[at]lucene.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>


emailgane at yahoo

Jul 2, 2009, 12:03 AM

Post #10 of 13 (591 views)
Permalink
Re: IndexWriter [In reply to]

No. You should not do this for every document you add or update.

First time, When you open your writer, if the directory is locked, it will throw LockObtainFailedException, In this case, Unlock it and Open the writer again.

Regards
Ganesh

----- Original Message -----
From: "Amin Mohammed-Coleman" <aminmc[at]gmail.com>
To: <java-user[at]lucene.apache.org>; <simon.willnauer[at]gmail.com>
Sent: Wednesday, July 01, 2009 5:39 PM
Subject: Re: IndexWriter


> Hi all
>
> Thanks for your response. I guess when I add or update using the
> indexwriter I need to do the following:
>
> }finally {
> if (IndexReader.isLocked(directory)) {
> IndexReader.unlock(directory);
> }
> }
>
>
> Cheers
> Amin
>
>
>
> On Wed, Jul 1, 2009 at 11:47 AM, Simon Willnauer <
> simon.willnauer[at]googlemail.com> wrote:
>
>> You might want to take care of the write.lock file in the index
>> directory if your application breaks down. If you do not close the
>> writer and restart you app you might get an LockObtainFailedException.
>>
>> simon
>>
>> On Wed, Jul 1, 2009 at 12:39 PM, Ganesh<emailgane[at]yahoo.co.in> wrote:
>> > Yes. Single IndexWriter could be maintained in a App and it could be
>> closed when the App is shutdown.
>> >
>> > Regards
>> > Ganesh
>> >
>> > ----- Original Message -----
>> > From: "Amin Mohammed-Coleman" <aminmc[at]gmail.com>
>> > To: <java-user[at]lucene.apache.org>
>> > Sent: Wednesday, July 01, 2009 1:27 PM
>> > Subject: IndexWriter
>> >
>> >
>> >> Hi
>> >>
>> >> This question has probably been asked before so apologies for asking it
>> >> again. Just to confirm that it is ok to use a single index writer in a
>> web
>> >> application and only close that single instance on application shutdown?
>> As
>> >> the indexwriter is thread safe there is no need for any external
>> >> synchronisation. Am I correct in thinking this?
>> >>
>> >> I have configured via spring a single index writer which is used in the
>> >> application and I use the same one for adding and updating documents.
>> This
>> >> index writer is closed when the spring application context shutsdown.
>> >>
>> >>
>> >> Cheers
>> >> Amin
>> >>
>> > Send instant messages to your online friends
>> http://in.messenger.yahoo.com
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
>> > For additional commands, e-mail: java-user-help[at]lucene.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
>> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>>
>>
>
Send instant messages to your online friends http://in.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org


simon.willnauer at googlemail

Jul 2, 2009, 12:06 AM

Post #11 of 13 (589 views)
Permalink
Re: IndexWriter [In reply to]

Ganesh is right you should check once you webapp is starting up if you
keep the writer open as long as you app is up and running. I just
mentioned it to make you aware of it and prevent some surprises if the
app crashes.

simon

On Thu, Jul 2, 2009 at 9:03 AM, Ganesh<emailgane[at]yahoo.co.in> wrote:
> No. You should not do this for every document you add or update.
>
> First time, When you open your writer, if the directory is locked, it will throw LockObtainFailedException, In this case, Unlock it and Open the writer again.
>
> Regards
> Ganesh
>
> ----- Original Message -----
> From: "Amin Mohammed-Coleman" <aminmc[at]gmail.com>
> To: <java-user[at]lucene.apache.org>; <simon.willnauer[at]gmail.com>
> Sent: Wednesday, July 01, 2009 5:39 PM
> Subject: Re: IndexWriter
>
>
>> Hi all
>>
>> Thanks for your response.  I guess when I add or update using the
>> indexwriter I need to do the following:
>>
>> }finally {
>>   if (IndexReader.isLocked(directory)) {
>>     IndexReader.unlock(directory);
>>   }
>> }
>>
>>
>> Cheers
>> Amin
>>
>>
>>
>> On Wed, Jul 1, 2009 at 11:47 AM, Simon Willnauer <
>> simon.willnauer[at]googlemail.com> wrote:
>>
>>> You might want to take care of the write.lock file in the index
>>> directory if your application breaks down. If you do not close the
>>> writer and restart you app you might get an LockObtainFailedException.
>>>
>>> simon
>>>
>>> On Wed, Jul 1, 2009 at 12:39 PM, Ganesh<emailgane[at]yahoo.co.in> wrote:
>>> > Yes. Single IndexWriter could be maintained in a App and it could be
>>> closed when the App is shutdown.
>>> >
>>> > Regards
>>> > Ganesh
>>> >
>>> > ----- Original Message -----
>>> > From: "Amin Mohammed-Coleman" <aminmc[at]gmail.com>
>>> > To: <java-user[at]lucene.apache.org>
>>> > Sent: Wednesday, July 01, 2009 1:27 PM
>>> > Subject: IndexWriter
>>> >
>>> >
>>> >> Hi
>>> >>
>>> >> This question has probably been asked before so apologies for asking it
>>> >> again.  Just to confirm that it is ok to use a single index writer in a
>>> web
>>> >> application and only close that single instance on application shutdown?
>>>  As
>>> >> the indexwriter is thread safe there is no need for any external
>>> >> synchronisation.  Am I correct in thinking this?
>>> >>
>>> >> I have configured via spring a single index writer which is used in the
>>> >> application and I use the same one for adding and updating documents.
>>>  This
>>> >> index writer is closed when the spring application context shutsdown.
>>> >>
>>> >>
>>> >> Cheers
>>> >> Amin
>>> >>
>>> > Send instant messages to your online friends
>>> http://in.messenger.yahoo.com
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
>>> > For additional commands, e-mail: java-user-help[at]lucene.apache.org
>>> >
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
>>> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>>>
>>>
>>
> Send instant messages to your online friends http://in.messenger.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org


aminmc at gmail

Jul 2, 2009, 12:55 AM

Post #12 of 13 (594 views)
Permalink
Re: IndexWriter [In reply to]

Ok

My index writers are configured using spring. So basically I need to have
spring application listener that checks on start up whether the directory is
locked if it is then unlock. On application shutdown i have a listener that
unlocks the directory if is locked.

Not sure if that made sense.

Cheers
Amin

On Thu, Jul 2, 2009 at 8:06 AM, Simon Willnauer <
simon.willnauer[at]googlemail.com> wrote:

> Ganesh is right you should check once you webapp is starting up if you
> keep the writer open as long as you app is up and running. I just
> mentioned it to make you aware of it and prevent some surprises if the
> app crashes.
>
> simon
>
> On Thu, Jul 2, 2009 at 9:03 AM, Ganesh<emailgane[at]yahoo.co.in> wrote:
> > No. You should not do this for every document you add or update.
> >
> > First time, When you open your writer, if the directory is locked, it
> will throw LockObtainFailedException, In this case, Unlock it and Open the
> writer again.
> >
> > Regards
> > Ganesh
> >
> > ----- Original Message -----
> > From: "Amin Mohammed-Coleman" <aminmc[at]gmail.com>
> > To: <java-user[at]lucene.apache.org>; <simon.willnauer[at]gmail.com>
> > Sent: Wednesday, July 01, 2009 5:39 PM
> > Subject: Re: IndexWriter
> >
> >
> >> Hi all
> >>
> >> Thanks for your response. I guess when I add or update using the
> >> indexwriter I need to do the following:
> >>
> >> }finally {
> >> if (IndexReader.isLocked(directory)) {
> >> IndexReader.unlock(directory);
> >> }
> >> }
> >>
> >>
> >> Cheers
> >> Amin
> >>
> >>
> >>
> >> On Wed, Jul 1, 2009 at 11:47 AM, Simon Willnauer <
> >> simon.willnauer[at]googlemail.com> wrote:
> >>
> >>> You might want to take care of the write.lock file in the index
> >>> directory if your application breaks down. If you do not close the
> >>> writer and restart you app you might get an LockObtainFailedException.
> >>>
> >>> simon
> >>>
> >>> On Wed, Jul 1, 2009 at 12:39 PM, Ganesh<emailgane[at]yahoo.co.in> wrote:
> >>> > Yes. Single IndexWriter could be maintained in a App and it could be
> >>> closed when the App is shutdown.
> >>> >
> >>> > Regards
> >>> > Ganesh
> >>> >
> >>> > ----- Original Message -----
> >>> > From: "Amin Mohammed-Coleman" <aminmc[at]gmail.com>
> >>> > To: <java-user[at]lucene.apache.org>
> >>> > Sent: Wednesday, July 01, 2009 1:27 PM
> >>> > Subject: IndexWriter
> >>> >
> >>> >
> >>> >> Hi
> >>> >>
> >>> >> This question has probably been asked before so apologies for asking
> it
> >>> >> again. Just to confirm that it is ok to use a single index writer
> in a
> >>> web
> >>> >> application and only close that single instance on application
> shutdown?
> >>> As
> >>> >> the indexwriter is thread safe there is no need for any external
> >>> >> synchronisation. Am I correct in thinking this?
> >>> >>
> >>> >> I have configured via spring a single index writer which is used in
> the
> >>> >> application and I use the same one for adding and updating
> documents.
> >>> This
> >>> >> index writer is closed when the spring application context
> shutsdown.
> >>> >>
> >>> >>
> >>> >> Cheers
> >>> >> Amin
> >>> >>
> >>> > Send instant messages to your online friends
> >>> http://in.messenger.yahoo.com
> >>> >
> >>> > ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> >>> > For additional commands, e-mail: java-user-help[at]lucene.apache.org
> >>> >
> >>> >
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> >>> For additional commands, e-mail: java-user-help[at]lucene.apache.org
> >>>
> >>>
> >>
> > Send instant messages to your online friends
> http://in.messenger.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> > For additional commands, e-mail: java-user-help[at]lucene.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>
>


simon.willnauer at googlemail

Jul 2, 2009, 1:05 AM

Post #13 of 13 (592 views)
Permalink
Re: IndexWriter [In reply to]

I don't know about your setup but you should do it before spring
creates you indexwriter. you could use a wrapper for that indexwriter
to unlock ahead of creating the delegate or rather have some startup
listener which checks if it is locked and in turn have a shutdown
listener which closes the writer.

simon



On Thu, Jul 2, 2009 at 9:55 AM, Amin Mohammed-Coleman<aminmc[at]gmail.com> wrote:
> Ok
>
> My index writers are configured using spring.  So basically I need to have
> spring application listener that checks on start up whether the directory is
> locked if it is then unlock.  On application shutdown i have a listener that
> unlocks the directory if is locked.
>
> Not sure if that made sense.
>
> Cheers
> Amin
>
> On Thu, Jul 2, 2009 at 8:06 AM, Simon Willnauer
> <simon.willnauer[at]googlemail.com> wrote:
>>
>> Ganesh is right you should check once you webapp is starting up if you
>> keep the writer open as long as you app is up and running. I just
>> mentioned it to make you aware of it and prevent some surprises if the
>> app crashes.
>>
>> simon
>>
>> On Thu, Jul 2, 2009 at 9:03 AM, Ganesh<emailgane[at]yahoo.co.in> wrote:
>> > No. You should not do this for every document you add or update.
>> >
>> > First time, When you open your writer, if the directory is locked, it
>> > will throw LockObtainFailedException, In this case, Unlock it and Open the
>> > writer again.
>> >
>> > Regards
>> > Ganesh
>> >
>> > ----- Original Message -----
>> > From: "Amin Mohammed-Coleman" <aminmc[at]gmail.com>
>> > To: <java-user[at]lucene.apache.org>; <simon.willnauer[at]gmail.com>
>> > Sent: Wednesday, July 01, 2009 5:39 PM
>> > Subject: Re: IndexWriter
>> >
>> >
>> >> Hi all
>> >>
>> >> Thanks for your response.  I guess when I add or update using the
>> >> indexwriter I need to do the following:
>> >>
>> >> }finally {
>> >>   if (IndexReader.isLocked(directory)) {
>> >>     IndexReader.unlock(directory);
>> >>   }
>> >> }
>> >>
>> >>
>> >> Cheers
>> >> Amin
>> >>
>> >>
>> >>
>> >> On Wed, Jul 1, 2009 at 11:47 AM, Simon Willnauer <
>> >> simon.willnauer[at]googlemail.com> wrote:
>> >>
>> >>> You might want to take care of the write.lock file in the index
>> >>> directory if your application breaks down. If you do not close the
>> >>> writer and restart you app you might get an LockObtainFailedException.
>> >>>
>> >>> simon
>> >>>
>> >>> On Wed, Jul 1, 2009 at 12:39 PM, Ganesh<emailgane[at]yahoo.co.in> wrote:
>> >>> > Yes. Single IndexWriter could be maintained in a App and it could be
>> >>> closed when the App is shutdown.
>> >>> >
>> >>> > Regards
>> >>> > Ganesh
>> >>> >
>> >>> > ----- Original Message -----
>> >>> > From: "Amin Mohammed-Coleman" <aminmc[at]gmail.com>
>> >>> > To: <java-user[at]lucene.apache.org>
>> >>> > Sent: Wednesday, July 01, 2009 1:27 PM
>> >>> > Subject: IndexWriter
>> >>> >
>> >>> >
>> >>> >> Hi
>> >>> >>
>> >>> >> This question has probably been asked before so apologies for
>> >>> >> asking it
>> >>> >> again.  Just to confirm that it is ok to use a single index writer
>> >>> >> in a
>> >>> web
>> >>> >> application and only close that single instance on application
>> >>> >> shutdown?
>> >>>  As
>> >>> >> the indexwriter is thread safe there is no need for any external
>> >>> >> synchronisation.  Am I correct in thinking this?
>> >>> >>
>> >>> >> I have configured via spring a single index writer which is used in
>> >>> >> the
>> >>> >> application and I use the same one for adding and updating
>> >>> >> documents.
>> >>>  This
>> >>> >> index writer is closed when the spring application context
>> >>> >> shutsdown.
>> >>> >>
>> >>> >>
>> >>> >> Cheers
>> >>> >> Amin
>> >>> >>
>> >>> > Send instant messages to your online friends
>> >>> http://in.messenger.yahoo.com
>> >>> >
>> >>> >
>> >>> > ---------------------------------------------------------------------
>> >>> > To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
>> >>> > For additional commands, e-mail: java-user-help[at]lucene.apache.org
>> >>> >
>> >>> >
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
>> >>> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>> >>>
>> >>>
>> >>
>> > Send instant messages to your online friends
>> > http://in.messenger.yahoo.com
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
>> > For additional commands, e-mail: java-user-help[at]lucene.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
>> For additional commands, e-mail: java-user-help[at]lucene.apache.org
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.