2021-07-06 01:30:37 +02:00
|
|
|
package it.cavallium.dbengine.lucene.searcher;
|
|
|
|
|
|
|
|
import it.cavallium.dbengine.client.query.QueryParser;
|
|
|
|
import it.cavallium.dbengine.client.query.current.data.QueryParams;
|
|
|
|
import org.apache.lucene.search.IndexSearcher;
|
|
|
|
import reactor.core.publisher.Flux;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
import reactor.core.scheduler.Scheduler;
|
|
|
|
|
|
|
|
public class CountLuceneLocalSearcher implements LuceneLocalSearcher {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Mono<LuceneSearchResult> collect(IndexSearcher indexSearcher,
|
2021-07-10 20:52:01 +02:00
|
|
|
Mono<Void> releaseIndexSearcher,
|
2021-07-06 01:30:37 +02:00
|
|
|
LocalQueryParams queryParams,
|
|
|
|
String keyFieldName,
|
|
|
|
Scheduler scheduler) {
|
|
|
|
//noinspection BlockingMethodInNonBlockingContext
|
|
|
|
return Mono
|
|
|
|
.fromCallable(() -> new LuceneSearchResult(
|
|
|
|
indexSearcher.count(queryParams.query()),
|
2021-07-10 20:52:01 +02:00
|
|
|
Flux.empty(),
|
|
|
|
releaseIndexSearcher)
|
2021-07-06 01:30:37 +02:00
|
|
|
)
|
|
|
|
.subscribeOn(scheduler);
|
|
|
|
}
|
|
|
|
}
|