Re: stop the search

2011-05-22 Thread Simon Willnauer
you can impl. you own collector and notify the collector to stop if you need to.
simon

On Sun, May 22, 2011 at 12:06 PM, liat oren  wrote:
> Hi Everyone,
>
> Is there a way to stop a multi search in the middle?
>
> Thanks a lot,
> Liat
>

-
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org



Re: stop the search

2011-05-22 Thread Devon H. O'Dell
I have my own collector, but implemented this functionality by running
the search in a thread pool and terminating the FutureTask running the
job if it took longer than some configurable amount of time. That
seemed to do the trick for me. (In my case, the IndexReader is
explicitly opened readonly, so I'm not too worried about it).

--dho

2011/5/22 Simon Willnauer :
> you can impl. you own collector and notify the collector to stop if you need 
> to.
> simon
>
> On Sun, May 22, 2011 at 12:06 PM, liat oren  wrote:
>> Hi Everyone,
>>
>> Is there a way to stop a multi search in the middle?
>>
>> Thanks a lot,
>> Liat
>>
>
> -
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>

-
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org



Re: stop the search

2011-05-22 Thread Simon Willnauer
On Sun, May 22, 2011 at 4:48 PM, Devon H. O'Dell  wrote:
> I have my own collector, but implemented this functionality by running
> the search in a thread pool and terminating the FutureTask running the
> job if it took longer than some configurable amount of time. That
> seemed to do the trick for me. (In my case, the IndexReader is
> explicitly opened readonly, so I'm not too worried about it).

This can be super dangerous if you use Future. cancel() ie.
Thread.interrupt(). If the interrupt is called while you are reading
from a NIO FileDescriptor the channel will be closed and Lucene can
not recover from that state if the file has already been merged away.
Your Reader will get ChannelAlreadyClosed exceptions for any
subsequent access. You should prevent this.
see FSDirectory Javadoc
http://lucene.apache.org/java/3_1_0/api/core/org/apache/lucene/store/FSDirectory.html

simon
>
> --dho
>
> 2011/5/22 Simon Willnauer :
>> you can impl. you own collector and notify the collector to stop if you need 
>> to.
>> simon
>>
>> On Sun, May 22, 2011 at 12:06 PM, liat oren  wrote:
>>> Hi Everyone,
>>>
>>> Is there a way to stop a multi search in the middle?
>>>
>>> Thanks a lot,
>>> Liat
>>>
>>
>> -
>> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
>> For additional commands, e-mail: java-user-h...@lucene.apache.org
>>
>>
>

-
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org



Re: stop the search

2011-05-22 Thread liat oren
Thank you very much.

So the best solution would be to implement the collector with a stop
function.
Do you happen to have an example for that?

Many thanks,
Liat

On 22 May 2011 13:19, Simon Willnauer wrote:

> On Sun, May 22, 2011 at 4:48 PM, Devon H. O'Dell 
> wrote:
> > I have my own collector, but implemented this functionality by running
> > the search in a thread pool and terminating the FutureTask running the
> > job if it took longer than some configurable amount of time. That
> > seemed to do the trick for me. (In my case, the IndexReader is
> > explicitly opened readonly, so I'm not too worried about it).
>
> This can be super dangerous if you use Future. cancel() ie.
> Thread.interrupt(). If the interrupt is called while you are reading
> from a NIO FileDescriptor the channel will be closed and Lucene can
> not recover from that state if the file has already been merged away.
> Your Reader will get ChannelAlreadyClosed exceptions for any
> subsequent access. You should prevent this.
> see FSDirectory Javadoc
>
> http://lucene.apache.org/java/3_1_0/api/core/org/apache/lucene/store/FSDirectory.html
>
> simon
> >
> > --dho
> >
> > 2011/5/22 Simon Willnauer :
> >> you can impl. you own collector and notify the collector to stop if you
> need to.
> >> simon
> >>
> >> On Sun, May 22, 2011 at 12:06 PM, liat oren 
> wrote:
> >>> Hi Everyone,
> >>>
> >>> Is there a way to stop a multi search in the middle?
> >>>
> >>> Thanks a lot,
> >>> Liat
> >>>
> >>
> >> -
> >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> >> For additional commands, e-mail: java-user-h...@lucene.apache.org
> >>
> >>
> >
>
> -
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>


Re: stop the search

2011-05-22 Thread Simon Willnauer
The simplest way would be a CollectorDelegate that wraps an existing
collector and checks a boolean before calling the delegates collect
method.

simon

On Mon, May 23, 2011 at 8:09 AM, liat oren  wrote:
> Thank you very much.
>
> So the best solution would be to implement the collector with a stop
> function.
> Do you happen to have an example for that?
>
> Many thanks,
> Liat
>
> On 22 May 2011 13:19, Simon Willnauer 
> wrote:
>>
>> On Sun, May 22, 2011 at 4:48 PM, Devon H. O'Dell 
>> wrote:
>> > I have my own collector, but implemented this functionality by running
>> > the search in a thread pool and terminating the FutureTask running the
>> > job if it took longer than some configurable amount of time. That
>> > seemed to do the trick for me. (In my case, the IndexReader is
>> > explicitly opened readonly, so I'm not too worried about it).
>>
>> This can be super dangerous if you use Future. cancel() ie.
>> Thread.interrupt(). If the interrupt is called while you are reading
>> from a NIO FileDescriptor the channel will be closed and Lucene can
>> not recover from that state if the file has already been merged away.
>> Your Reader will get ChannelAlreadyClosed exceptions for any
>> subsequent access. You should prevent this.
>> see FSDirectory Javadoc
>>
>> http://lucene.apache.org/java/3_1_0/api/core/org/apache/lucene/store/FSDirectory.html
>>
>> simon
>> >
>> > --dho
>> >
>> > 2011/5/22 Simon Willnauer :
>> >> you can impl. you own collector and notify the collector to stop if you
>> >> need to.
>> >> simon
>> >>
>> >> On Sun, May 22, 2011 at 12:06 PM, liat oren 
>> >> wrote:
>> >>> Hi Everyone,
>> >>>
>> >>> Is there a way to stop a multi search in the middle?
>> >>>
>> >>> Thanks a lot,
>> >>> Liat
>> >>>
>> >>
>> >> -
>> >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
>> >> For additional commands, e-mail: java-user-h...@lucene.apache.org
>> >>
>> >>
>> >
>>
>> -
>> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
>> For additional commands, e-mail: java-user-h...@lucene.apache.org
>>
>
>

-
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org



Re: stop the search

2011-05-23 Thread liat oren
Thanks a lot.

I tried to debug a long query and see when it gets to the collector.

I thought it will be better to catch the "stop" action in the search itself
and not the top doc collector as I would assume the search action will take
long time to finish and once we get to the top doc collector, it will return
immediately (I take only the top 100 results)

I saw that it gets there after a long time - it first "gets stuck" on a wait
function.

I use MultiSearcher - any idea why that happens?

Many Thanks,
Liat

On 23 May 2011 02:48, Simon Willnauer wrote:

> The simplest way would be a CollectorDelegate that wraps an existing
> collector and checks a boolean before calling the delegates collect
> method.
>
> simon
>
> On Mon, May 23, 2011 at 8:09 AM, liat oren  wrote:
> > Thank you very much.
> >
> > So the best solution would be to implement the collector with a stop
> > function.
> > Do you happen to have an example for that?
> >
> > Many thanks,
> > Liat
> >
> > On 22 May 2011 13:19, Simon Willnauer 
> > wrote:
> >>
> >> On Sun, May 22, 2011 at 4:48 PM, Devon H. O'Dell  >
> >> wrote:
> >> > I have my own collector, but implemented this functionality by running
> >> > the search in a thread pool and terminating the FutureTask running the
> >> > job if it took longer than some configurable amount of time. That
> >> > seemed to do the trick for me. (In my case, the IndexReader is
> >> > explicitly opened readonly, so I'm not too worried about it).
> >>
> >> This can be super dangerous if you use Future. cancel() ie.
> >> Thread.interrupt(). If the interrupt is called while you are reading
> >> from a NIO FileDescriptor the channel will be closed and Lucene can
> >> not recover from that state if the file has already been merged away.
> >> Your Reader will get ChannelAlreadyClosed exceptions for any
> >> subsequent access. You should prevent this.
> >> see FSDirectory Javadoc
> >>
> >>
> http://lucene.apache.org/java/3_1_0/api/core/org/apache/lucene/store/FSDirectory.html
> >>
> >> simon
> >> >
> >> > --dho
> >> >
> >> > 2011/5/22 Simon Willnauer :
> >> >> you can impl. you own collector and notify the collector to stop if
> you
> >> >> need to.
> >> >> simon
> >> >>
> >> >> On Sun, May 22, 2011 at 12:06 PM, liat oren 
> >> >> wrote:
> >> >>> Hi Everyone,
> >> >>>
> >> >>> Is there a way to stop a multi search in the middle?
> >> >>>
> >> >>> Thanks a lot,
> >> >>> Liat
> >> >>>
> >> >>
> >> >> -
> >> >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> >> >> For additional commands, e-mail: java-user-h...@lucene.apache.org
> >> >>
> >> >>
> >> >
> >>
> >> -
> >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> >> For additional commands, e-mail: java-user-h...@lucene.apache.org
> >>
> >
> >
>