Pass TopDocsCollector as the first arg into TimeLimitingCollector.

On Thu, Feb 27, 2020 at 2:31 PM <baris.ka...@oracle.com> wrote:

> Hi,-
>
> Sometimes the search takes too long even with PhraseWildcardQuery, so i
> would like to limit the search time via TimeLimitingCollector API.
>
>
> Thanks to Mikhail and this Forum to inform me about this API.
>
>
> i checked this IndexSearcher API with Collector parameter but that API
> does not have top n results as parameter:
>
>
> https://lucene.apache.org/core/8_4_1/core/org/apache/lucene/search/IndexSearcher.html
>
>
> and the TimeLimitingCollector API:
>
>
> https://lucene.apache.org/core/8_4_1/core/org/apache/lucene/search/TimeLimitingCollector.html
>
>
> Is there a simple example where both IndexSearcher and
> TimeLimitingCollector APIs are combined?
>
> I found this snippet and i would like to add the missing pieces here:
>
>
> Counter clock = ...;
> long baseline = clock.get();
> // ... prepare search -> i think this means create the query here
> TimeLimitingCollector collector = new TimeLimitingCollector(c, clock,
> numTicks);
> collector.setBaseline(baseline);
> indexSearcher.search(query, collector);
>
> // But i also would like to do the following: and how do i get results
> from TimeLimitingCollector in that so much allowed time?
>
> int totalHits = collector.totalHits;
>
> TopDocs topdocs = collector.topdocs(); // But i cant specify Top n docs
> here, right?
>
>
> The collector is defined here
>
>
> https://lucene.apache.org/core/8_4_1/core/org/apache/lucene/search/Collector.html
>
>
> https://lucene.apache.org/core/8_4_1/core/org/apache/lucene/search/TopDocsCollector.html
>
> Best regards
>
>
>
> On 2/25/20 1:50 AM, baris.ka...@oracle.com wrote:
> > Will do, Thanks
> >
> >
> >> On Feb 25, 2020, at 1:34 AM, Mikhail Khludnev <m...@apache.org> wrote:
> >>
> >> Hello.
> >>
> >> Meet org.apache.lucene.search.TimeLimitingCollector.
> >>
> >>> On Mon, Feb 24, 2020 at 2:51 PM <baris.ka...@oracle.com> wrote:
> >>>
> >>> Hi,-
> >>>
> >>> I hope everyone is doing great.
> >>>
> >>>
> >>> i am trying to find an api to tell Lucene Index Searcher to stop after
> >>> 0.5 seconds (when it takes longer than this).
> >>>
> >>> Is there such an api or plan to implement one?
> >>>
> >>>
> >>> Best regards
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> >>> For additional commands, e-mail: java-user-h...@lucene.apache.org
> >>>
> >>>
> >> --
> >> Sincerely yours
> >> Mikhail Khludnev
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>

-- 
Sincerely yours
Mikhail Khludnev

Reply via email to