Eric Yin
Eric Yin

Reputation: 8983

Force Lucene.NET to show results in N seconds

I like to get response from Lucene.NET after N seconds, even no results yet. How?

Currently I am facing a problem. All Lucene.NET index is located in a central place, and each instance, after reboot, have to copy the index to local before search can happen.

The copy will be initiated after first Lucene.NET request and take few minutes to complete. Currently all Lucene.NET just hung and wait, so I like to FORCE them to response no matter what.

Please help.

[EIDT]

So the path is using TimeLimitingCollector, this gives me another question, how to use multiple connector together?

My original code is:

TopFieldCollector collector = TopFieldCollector.create(Sort.RELEVANCE, resultAmount,
                            false,
                            true /* trackDocScores */,
                            true /* trackMaxScore */,
                            false /* docsInOrder */);
                        searcher.Search(query, new PositiveScoresOnlyCollector(collector));

Where should I put TimeLimitingCollector?

Upvotes: 0

Views: 165

Answers (1)

jpountz
jpountz

Reputation: 9964

You can use a TimeLimitingCollector.

[EDIT]

I am not familiar with Lucene.NET, but with Lucene Java you just need to wrap your collector inside a TimeLimitingCollector, and it will throw a time-out exception whenever trying to collect a document too late.

Upvotes: 2

Related Questions