package it.cavallium.dbengine.database; import com.google.common.collect.Multimap; import it.cavallium.dbengine.client.query.current.data.NoSort; import it.cavallium.dbengine.client.query.current.data.Query; import it.cavallium.dbengine.client.query.current.data.QueryParams; import it.cavallium.dbengine.client.query.current.data.TotalHitsCount; import it.cavallium.dbengine.lucene.collector.Buckets; import it.cavallium.dbengine.lucene.searcher.BucketParams; import java.util.List; import java.util.Map; import java.util.Map.Entry; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; public interface LLLuceneIndex extends LLSnapshottable { String getLuceneIndexName(); Mono addDocument(LLTerm id, LLUpdateDocument doc); Mono addDocuments(boolean atomic, Flux> documents); Mono deleteDocument(LLTerm id); Mono update(LLTerm id, LLIndexRequest request); Mono updateDocuments(Flux> documents); Mono deleteAll(); /** * @param queryParams the limit is valid for each lucene instance. If you have 15 instances, the number of elements * returned can be at most limit * 15. *

* The additional query will be used with the moreLikeThis query: "mltQuery AND additionalQuery" * @return the collection has one or more flux */ Flux moreLikeThis(@Nullable LLSnapshot snapshot, QueryParams queryParams, @Nullable String keyFieldName, Multimap mltDocumentFields); /** * @param queryParams the limit is valid for each lucene instance. If you have 15 instances, the number of elements * returned can be at most limit * 15 * @return the collection has one or more flux */ Flux search(@Nullable LLSnapshot snapshot, QueryParams queryParams, @Nullable String keyFieldName); /** * @return buckets with each value collected into one of the buckets */ Mono computeBuckets(@Nullable LLSnapshot snapshot, @NotNull List queries, @Nullable Query normalizationQuery, BucketParams bucketParams); default Mono count(@Nullable LLSnapshot snapshot, Query query) { QueryParams params = QueryParams.of(query, 0, 0, NoSort.of(), false, Long.MAX_VALUE); return Mono.from(this.search(snapshot, params, null) .map(llSearchResultShard -> { try (llSearchResultShard) { return llSearchResultShard.totalHitsCount(); } }) .defaultIfEmpty(TotalHitsCount.of(0, true)) ); } boolean isLowMemoryMode(); Mono close(); /** * Flush writes to disk. * This does not commit, it syncs the data to the disk */ Mono flush(); /** * Refresh index searcher */ Mono refresh(boolean force); }