2020-12-07 22:15:18 +01:00
|
|
|
package it.cavallium.dbengine.database;
|
|
|
|
|
2021-02-03 13:48:30 +01:00
|
|
|
import it.cavallium.dbengine.lucene.serializer.Query;
|
2020-12-07 22:15:18 +01:00
|
|
|
import java.util.Set;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
2021-01-30 19:57:50 +01:00
|
|
|
import reactor.core.publisher.Flux;
|
|
|
|
import reactor.core.publisher.GroupedFlux;
|
2020-12-07 22:15:18 +01:00
|
|
|
import reactor.core.publisher.Mono;
|
2021-01-30 19:57:50 +01:00
|
|
|
import reactor.util.function.Tuple2;
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2021-01-30 01:41:04 +01:00
|
|
|
public interface LLLuceneIndex extends LLSnapshottable {
|
2020-12-07 22:15:18 +01:00
|
|
|
|
|
|
|
String getLuceneIndexName();
|
|
|
|
|
2021-01-30 01:41:04 +01:00
|
|
|
Mono<Void> addDocument(LLTerm id, LLDocument doc);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2021-01-30 19:57:50 +01:00
|
|
|
Mono<Void> addDocuments(Flux<GroupedFlux<LLTerm, LLDocument>> 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-01-30 01:41:04 +01:00
|
|
|
Mono<Void> updateDocument(LLTerm id, LLDocument document);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2021-01-30 19:57:50 +01:00
|
|
|
Mono<Void> updateDocuments(Flux<GroupedFlux<LLTerm, LLDocument>> 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-02-27 17:32:57 +01:00
|
|
|
* @param additionalQuery An additional query that will be used with the moreLikeThis query: "mltQuery AND additionalQuery"
|
2020-12-08 10:52:15 +01:00
|
|
|
* @param limit 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>
|
2021-01-29 17:19:01 +01:00
|
|
|
* @return the collection has one or more flux
|
2020-12-08 10:52:15 +01:00
|
|
|
*/
|
2021-01-29 17:19:01 +01:00
|
|
|
Mono<LLSearchResult> moreLikeThis(@Nullable LLSnapshot snapshot,
|
2021-01-30 19:57:50 +01:00
|
|
|
Flux<Tuple2<String, Set<String>>> mltDocumentFields,
|
2021-02-27 17:32:57 +01:00
|
|
|
@Nullable it.cavallium.dbengine.lucene.serializer.Query additionalQuery,
|
2021-02-22 01:37:17 +01:00
|
|
|
long limit,
|
2021-02-14 13:46:11 +01:00
|
|
|
@Nullable Float minCompetitiveScore,
|
2021-02-28 16:11:50 +01:00
|
|
|
boolean enableScoring,
|
2021-02-28 16:50:59 +01:00
|
|
|
boolean sortByScore,
|
2021-01-29 17:19:01 +01:00
|
|
|
String keyFieldName);
|
2020-12-07 22:15:18 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2020-12-08 10:51:21 +01:00
|
|
|
* @param limit 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
|
|
|
|
*/
|
2021-01-29 17:19:01 +01:00
|
|
|
Mono<LLSearchResult> search(@Nullable LLSnapshot snapshot,
|
2021-02-03 13:48:30 +01:00
|
|
|
Query query,
|
2021-02-22 01:37:17 +01:00
|
|
|
long limit,
|
2020-12-07 22:15:18 +01:00
|
|
|
@Nullable LLSort sort,
|
2021-01-29 17:19:01 +01:00
|
|
|
LLScoreMode scoreMode,
|
2021-02-14 13:46:11 +01:00
|
|
|
@Nullable Float minCompetitiveScore,
|
2020-12-07 22:15:18 +01:00
|
|
|
String keyFieldName);
|
|
|
|
|
2021-02-03 13:48:30 +01:00
|
|
|
default Mono<Long> count(@Nullable LLSnapshot snapshot, Query query) {
|
2021-02-14 13:46:11 +01:00
|
|
|
return this.search(snapshot, query, 0, null, null, null, null)
|
2021-01-30 01:41:04 +01:00
|
|
|
.flatMap(LLSearchResult::totalHitsCount)
|
|
|
|
.single();
|
|
|
|
}
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Flush writes to disk
|
|
|
|
*/
|
|
|
|
Mono<Void> flush();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Refresh index searcher
|
|
|
|
*/
|
|
|
|
Mono<Void> refresh();
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|