lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: re-use IndexWriter
Date Tue, 08 Jul 2014 13:47:44 GMT
Read the javadocs to understand the difference between commit() and
flush().  You need commit(), or close().

There are no hard and fast rules and it depends on how much data you
are indexing, how fast, how many searches you're getting and how up to
date they need to be.  And how much you worry about losing indexed
data.

One option is to pick a value that makes sense to you and commit() the
writer every n seconds|minutes|hours|docs.  close() it when your
indexing job exits.  You'll need to reopen index searchers to pick up
changes.  See the javadocs for IndexSearcher.

Another option is to use lucene's near-real-time (NRT) features.  Also
see the IndexSearcher javadocs for a way in to that.


--
Ian.


On Tue, Jul 8, 2014 at 10:08 AM, Jason.H <469673467@qq.com> wrote:
> nowadays , i've been trying every way to improve the performance of indexing , IndexWriter's
close operation is really costly , and the Lucene's doc sugguest to re-use IndexWriter instance
, i  did it , i  kept the indexWriter instance , and give it back to every request thread
, But there comes a big problem ,  i never search the index changes because the index changes
is till in the RAM , maybe there's a way to flush all the changes to the stable Storage and
this operation don't close the IndexWriter so i could re-use it  . am i right at this point
?
>
> there're several point i don't quite understand ..
>
> 1, what's the difference between commit and flush  ?   i thought with these two method
, i could see the changes in my Directory without closing IndexWriter .
>
> 2, when should i close the writer ? if i use it Singleton(i don't have to worry about
the LockObtainException) , and i don't have to worry about the changes because commit and
flush would do this , then i don't have to close it any more ...

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