2020-12-07 22:15:18 +01:00
|
|
|
package it.cavallium.dbengine.database;
|
|
|
|
|
2022-01-28 19:31:25 +01:00
|
|
|
import com.google.common.collect.Multimap;
|
2021-03-02 01:53:36 +01:00
|
|
|
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;
|
2021-08-04 01:12:39 +02:00
|
|
|
import it.cavallium.dbengine.client.query.current.data.TotalHitsCount;
|
2021-11-19 19:03:31 +01:00
|
|
|
import it.cavallium.dbengine.lucene.collector.Buckets;
|
2021-11-18 17:13:53 +01:00
|
|
|
import it.cavallium.dbengine.lucene.searcher.BucketParams;
|
2021-11-19 19:03:31 +01:00
|
|
|
import java.util.List;
|
2021-05-11 21:59:05 +02:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map.Entry;
|
2021-11-19 19:03:31 +01:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2020-12-07 22:15:18 +01:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2021-01-30 19:57:50 +01:00
|
|
|
import reactor.core.publisher.Flux;
|
2020-12-07 22:15:18 +01:00
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
2021-01-30 01:41:04 +01:00
|
|
|
public interface LLLuceneIndex extends LLSnapshottable {
|
2020-12-07 22:15:18 +01:00
|
|
|
|
|
|
|
String getLuceneIndexName();
|
|
|
|
|
2021-11-07 17:46:40 +01:00
|
|
|
Mono<Void> addDocument(LLTerm id, LLUpdateDocument doc);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-03-19 00:08:23 +01:00
|
|
|
Mono<Long> addDocuments(boolean atomic, Flux<Entry<LLTerm, LLUpdateDocument>> documents);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2021-01-30 01:41:04 +01:00
|
|
|
Mono<Void> deleteDocument(LLTerm id);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2021-11-07 17:46:40 +01:00
|
|
|
Mono<Void> update(LLTerm id, LLIndexRequest request);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2022-03-19 00:08:23 +01:00
|
|
|
Mono<Long> updateDocuments(Flux<Entry<LLTerm, LLUpdateDocument>> documents);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2021-01-30 01:41:04 +01:00
|
|
|
Mono<Void> deleteAll();
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2020-12-08 10:52:15 +01:00
|
|
|
/**
|
2021-03-02 01:53:36 +01:00
|
|
|
* @param queryParams the limit is valid for each lucene instance. If you have 15 instances, the number of elements
|
|
|
|
* returned can be at most <code>limit * 15</code>.
|
|
|
|
* <p>
|
|
|
|
* The additional query will be used with the moreLikeThis query: "mltQuery AND additionalQuery"
|
2021-01-29 17:19:01 +01:00
|
|
|
* @return the collection has one or more flux
|
2020-12-08 10:52:15 +01:00
|
|
|
*/
|
2022-03-05 15:46:40 +01:00
|
|
|
Flux<LLSearchResultShard> moreLikeThis(@Nullable LLSnapshot snapshot,
|
2021-03-02 01:53:36 +01:00
|
|
|
QueryParams queryParams,
|
2022-02-26 03:28:20 +01:00
|
|
|
@Nullable String keyFieldName,
|
2022-01-28 19:31:25 +01:00
|
|
|
Multimap<String, String> mltDocumentFields);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
|
|
|
/**
|
2021-03-02 01:53:36 +01:00
|
|
|
* @param queryParams the limit is valid for each lucene instance. If you have 15 instances, the number of elements
|
|
|
|
* returned can be at most <code>limit * 15</code>
|
2020-12-07 22:15:18 +01:00
|
|
|
* @return the collection has one or more flux
|
|
|
|
*/
|
2022-03-05 15:46:40 +01:00
|
|
|
Flux<LLSearchResultShard> search(@Nullable LLSnapshot snapshot,
|
2022-02-26 03:28:20 +01:00
|
|
|
QueryParams queryParams,
|
|
|
|
@Nullable String keyFieldName);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2021-11-18 17:13:53 +01:00
|
|
|
/**
|
|
|
|
* @return buckets with each value collected into one of the buckets
|
|
|
|
*/
|
2021-11-19 19:03:31 +01:00
|
|
|
Mono<Buckets> computeBuckets(@Nullable LLSnapshot snapshot,
|
|
|
|
@NotNull List<Query> queries,
|
|
|
|
@Nullable Query normalizationQuery,
|
|
|
|
BucketParams bucketParams);
|
2021-11-18 17:13:53 +01:00
|
|
|
|
2021-08-04 01:12:39 +02:00
|
|
|
default Mono<TotalHitsCount> count(@Nullable LLSnapshot snapshot, Query query) {
|
2022-02-11 13:32:50 +01:00
|
|
|
QueryParams params = QueryParams.of(query, 0, 0, NoSort.of(), false, Long.MAX_VALUE);
|
2021-03-03 15:03:25 +01:00
|
|
|
return Mono.from(this.search(snapshot, params, null)
|
2021-11-08 11:17:52 +01:00
|
|
|
.map(llSearchResultShard -> {
|
|
|
|
try (llSearchResultShard) {
|
2021-09-18 18:34:21 +02:00
|
|
|
return llSearchResultShard.totalHitsCount();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.defaultIfEmpty(TotalHitsCount.of(0, true))
|
2022-01-26 14:22:54 +01:00
|
|
|
);
|
2021-01-30 01:41:04 +01:00
|
|
|
}
|
2020-12-07 22:15:18 +01:00
|
|
|
|
|
|
|
boolean isLowMemoryMode();
|
2021-01-30 01:41:04 +01:00
|
|
|
|
|
|
|
Mono<Void> close();
|
2021-02-03 13:48:30 +01:00
|
|
|
|
|
|
|
/**
|
2021-11-20 01:30:06 +01:00
|
|
|
* Flush writes to disk.
|
|
|
|
* This does not commit, it syncs the data to the disk
|
2021-02-03 13:48:30 +01:00
|
|
|
*/
|
|
|
|
Mono<Void> flush();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Refresh index searcher
|
|
|
|
*/
|
2021-07-18 19:37:24 +02:00
|
|
|
Mono<Void> refresh(boolean force);
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|