Searches in Lucene.NET are usually very fast. This is by design with the use of an inverted index model to make lookups highly efficient. But in the case where a complicated search, complex ordering, or having too large an index causes a search to take longer than desired, it is possible to cancel the search.
Searches in Lucene.NET can be canceled by passing an instance of
TimeLimitingCollector to the search method of
IndexSearcher. The code for the example contains a method named
searchWithTimeout in the example's facade that demonstrates the concept. It executes two searches for "morlocks", with the first search having a timeout of 1 ms, and the second having a timeout of 100 ms.