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

Switch to Threaded View
Lucene, mail # user - Configure writer to write to FSDirectory?


Copy link to this message
-
Re: Configure writer to write to FSDirectory?
Michael McCandless 2012-02-06, 16:42
You shouldn't call IW.commit when using NRT; that's the point of NRT
(making changes visible w/o calling commit).

Only call commit when you require that all changes be durable (surive
OS / JVM crash, power loss, etc.) on disk.

Also, you can use NRTCachingDirectory which acts like RAMDirectory for
small flushed segments.

Mike McCandless

http://blog.mikemccandless.com

On Mon, Feb 6, 2012 at 10:45 AM, Cheng <[EMAIL PROTECTED]> wrote:
> Uwe, when I meant speed is slow, I didn't refer to instant visibility of
> changes, but that the changes may be synchronized with FSDirectory when I
> use writer.commit().
>
> When I use RAMDirectory, the writer.commit() seems much faster than using
> NRTManager built upon FSDirectory. So, I am guessing the difference is the
> index synchronization.
>
>
>
> On Mon, Feb 6, 2012 at 11:40 PM, Uwe Schindler <[EMAIL PROTECTED]> wrote:
>
>> Please review the following articles about NRT, absolutely instant updates
>> that are visible as they are done are almost impossible (even with
>> RAMDirectory):
>>
>> http://goo.gl/mzAHt
>> http://goo.gl/5RoPx
>> http://goo.gl/vSJ7x
>>
>> Uwe
>>
>> -----
>> Uwe Schindler
>> H.-H.-Meier-Allee 63, D-28213 Bremen
>> http://www.thetaphi.de
>> eMail: [EMAIL PROTECTED]
>>
>> > -----Original Message-----
>> > From: Cheng [mailto:[EMAIL PROTECTED]]
>> > Sent: Monday, February 06, 2012 4:27 PM
>> > To: [EMAIL PROTECTED]
>> > Subject: Re: Configure writer to write to FSDirectory?
>> >
>> > Ian,
>> >
>> > I encountered an issue that I need to frequently update the index. The
>> > NRTManager seems not very helpful on this front as the speed is slower
>> than
>> > RAMDirectory is used.
>> >
>> > Any improvement advice?
>> >
>> >
>> >
>> > On Mon, Feb 6, 2012 at 10:24 PM, Cheng <[EMAIL PROTECTED]> wrote:
>> >
>> > > That really helps! I will try it out.
>> > >
>> > > Thanks.
>> > >
>> > >
>> > > On Mon, Feb 6, 2012 at 10:12 PM, Ian Lea <[EMAIL PROTECTED]> wrote:
>> > >
>> > >> You would use NRTManagerReopenThread as a standalone thread, not
>> > >> plugged into your Executor stuff.  It is a utility class which you
>> > >> don't have to use.  See the javadocs.
>> > >>
>> > >> But in your case I'd use it, to start with anyway.  Fire it up with
>> > >> suitable settings and forget about it, except to call close()
>> > >> eventually. Once you've got things up and running you can tweak
>> > >> things as much as you want but you appear to be having trouble
>> > >> getting up and running.
>> > >>
>> > >> So ... somewhere in the initialisation code of your app, create an
>> > >> IndexWriter, NRTManager + ReopenThread and SearcherManager as
>> > >> outlined before.  Then pass the NRTManager to any/all write methods
>> > >> or threads and the SearcherManager instance to any/all search methods
>> > >> or threads and you're done.  If you want to use threads that are part
>> > >> of your ExecutorService, fine.  Just wrap it all together in whatever
>> > >> combination of Thread or Runnable instances you want.
>> > >>
>> > >>
>> > >> Does that help?
>> > >>
>> > >>
>> > >> --
>> > >> Ian.
>> > >>
>> > >>
>> > >> > I don't understand this following portion:
>> > >> >
>> > >> > IndexWriter iw = new IndexWriter(whatever - some standard disk
>> > >> > index); NRTManager nrtm = new NRTManager(iw, null);
>> > >> > NRTManagerReopenThread ropt = new NRTManagerReopenThread(nrtm,
>> > >> > ...); ropt.setXxx(...); ....
>> > >> > ropt.start();
>> > >> >
>> > >> > I have a java ExecutorServices instance running which take care of
>> > >> > my
>> > >> own
>> > >> > applications. I don't know how this NRTManagerReopenThread works
>> > >> > with my own ExecutorService instance.
>> > >> >
>> > >> > Can both work together? How can the NRTManagerReopenThread
>> > instance
>> > >> ropt be
>> > >> > plugged into my own multithreading framework?
>> > >> >
>> > >> > On Mon, Feb 6, 2012 at 8:17 PM, Ian Lea <[EMAIL PROTECTED]> wrote:
>> > >> >
>> > >> >> If you can use NRTManager and SearcherManager things should be