lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheng <zhoucheng2...@gmail.com>
Subject Re: Is it necessary to create a new searcher?
Date Sun, 15 Jan 2012 06:07:29 GMT
I just found some interesting stuff here:

https://builds.apache.org/job/Lucene-3.x/javadoc/contrib-misc/org/apache/lucene/index/NRTManagerReopenThread.html



How the NRTManager is plugged into my executeservice framework?

On Sun, Jan 15, 2012 at 1:04 AM, Cheng <zhoucheng2008@gmail.com> wrote:

> That sounds like what I am looking for. But do you have some code example
> about how to use this NRTManager?
>
>
> On Fri, Jan 13, 2012 at 12:05 PM, Ian Lea <ian.lea@gmail.com> wrote:
>
>> The javadocs for oal.search.SearcherManager start "Utility class to
>> safely share IndexSearcher instances across multiple threads, while
>> periodically reopening."  The maybeReopen() method does what you would
>> expect and can be called from multiple threads.
>>
>> Isn't that exactly what you need?  See also oal.search.NRTManager.
>>
>>
>> --
>> Ian.
>>
>>
>> On Fri, Jan 13, 2012 at 4:06 PM, dyzc2010 <zhoucheng2008@gmail.com>
>> wrote:
>> > Thanks for pointing that out for me. I will change the code.
>> >
>> >
>> > My challenge is that I use a same reader for multiple threads. So if I
>> have to close a reader within a thread, the others may be affected. With
>> that, what can I do within a thread to reopen a new reader?
>> >
>> >
>> > ------------------ Original ------------------
>> > From:  "Ian Lea"<ian.lea@gmail.com>;
>> > Date:  Fri, Jan 13, 2012 05:47 PM
>> > To:  "java-user"<java-user@lucene.apache.org>;
>> >
>> > Subject:  Re: Is it necessary to create a new searcher?
>> >
>> >
>> > The javadocs for openIfChanged say that it returns null if not
>> > changed, so I don't think your code will work as is.  You need to
>> > check the return value and you'll need to close the old reader if you
>> > have been given a new one.
>> >
>> > If you are going to be reopening if changed, there seems little point
>> > in calling isCurrent() rather than openIfChanged().  Searchers are
>> > based on readers and readers are tied to a segment and if only one or
>> > two segments have changed, only those readers will be reopened.
>> > So in general, a reopen after a small number of updates may well be
>> > quicker than a reopen after a large number of updates.  How important
>> > is it that your searches get up to date data? If vital, you'll have to
>> > reopen.  If not so vital you could instead reopen every now and again.
>> >
>> > You should take a look at NRTManager and NRTManagerReopenThread.
>> > There's good info in the javadocs.
>> >
>> >
>> > --
>> > Ian.
>> >
>> >
>> > On Wed, Jan 11, 2012 at 10:51 PM, Cheng <zhoucheng2008@gmail.com>
>> wrote:
>> >> I am currently using the following statement at the end of each index
>> >> writing, although I don't know if the writing modifies the indexes or
>> not:
>> >>
>> >> is = new IndexSearcher(IndexReader.openIfChanged(ir));
>> >>
>> >> # is -> IndexSearcher, ir-> IndexReader
>> >>
>> >>
>> >> My question is how expensive to create a searcher instance (I have
>> >> potentially hundreds of thousands of docs added or modified so the
>> cost to
>> >> create a new searcher instance may be unbearable.)
>> >>
>> >> Should I use the IndexReader.isCurrent() instead to check if is
>> current?
>> >>
>> >> Thanks
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> > For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message