CavalliumDBEngine/src/main/java/it/cavallium/dbengine/database/LLLuceneIndex.java

78 lines
2.2 KiB
Java
Raw Normal View History

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;
import reactor.core.publisher.Flux;
import reactor.core.publisher.GroupedFlux;
2020-12-07 22:15:18 +01:00
import reactor.core.publisher.Mono;
import reactor.util.function.Tuple2;
2020-12-07 22:15:18 +01:00
public interface LLLuceneIndex extends LLSnapshottable {
2020-12-07 22:15:18 +01:00
String getLuceneIndexName();
Mono<Void> addDocument(LLTerm id, LLDocument doc);
2020-12-07 22:15:18 +01:00
Mono<Void> addDocuments(Flux<GroupedFlux<LLTerm, LLDocument>> documents);
2020-12-07 22:15:18 +01:00
Mono<Void> deleteDocument(LLTerm id);
2020-12-07 22:15:18 +01:00
Mono<Void> updateDocument(LLTerm id, LLDocument document);
2020-12-07 22:15:18 +01:00
Mono<Void> updateDocuments(Flux<GroupedFlux<LLTerm, LLDocument>> documents);
2020-12-07 22:15:18 +01:00
Mono<Void> deleteAll();
2020-12-07 22:15:18 +01:00
2020-12-08 10:52:15 +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>
* @return the collection has one or more flux
2020-12-08 10:52:15 +01:00
*/
Mono<LLSearchResult> moreLikeThis(@Nullable LLSnapshot snapshot,
Flux<Tuple2<String, Set<String>>> mltDocumentFields,
@Nullable it.cavallium.dbengine.lucene.serializer.Query additionalQuery,
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,
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
*/
Mono<LLSearchResult> search(@Nullable LLSnapshot snapshot,
2021-02-03 13:48:30 +01:00
Query query,
long limit,
2020-12-07 22:15:18 +01:00
@Nullable LLSort sort,
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)
.flatMap(LLSearchResult::totalHitsCount)
.single();
}
2020-12-07 22:15:18 +01:00
boolean isLowMemoryMode();
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
}