Add soft update document
This commit is contained in:
parent
52be944b5f
commit
b48ab0b095
@ -1,6 +1,7 @@
|
|||||||
package it.cavallium.dbengine.client;
|
package it.cavallium.dbengine.client;
|
||||||
|
|
||||||
import it.cavallium.dbengine.database.LLIndexRequest;
|
import it.cavallium.dbengine.database.LLIndexRequest;
|
||||||
|
import it.cavallium.dbengine.database.LLSoftUpdateDocument;
|
||||||
import it.cavallium.dbengine.database.LLUpdateDocument;
|
import it.cavallium.dbengine.database.LLUpdateDocument;
|
||||||
import it.cavallium.dbengine.database.LLTerm;
|
import it.cavallium.dbengine.database.LLTerm;
|
||||||
import it.cavallium.dbengine.database.LLUpdateFields;
|
import it.cavallium.dbengine.database.LLUpdateFields;
|
||||||
@ -24,6 +25,8 @@ public abstract class Indicizer<T, U> {
|
|||||||
return new LLUpdateDocument(updateFields.items());
|
return new LLUpdateDocument(updateFields.items());
|
||||||
} else if (req instanceof LLUpdateDocument updateDocument) {
|
} else if (req instanceof LLUpdateDocument updateDocument) {
|
||||||
return updateDocument;
|
return updateDocument;
|
||||||
|
} else if (req instanceof LLSoftUpdateDocument softUpdateDocument) {
|
||||||
|
return new LLUpdateDocument(softUpdateDocument.items());
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("Unexpected request type: " + req);
|
throw new UnsupportedOperationException("Unexpected request type: " + req);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
package it.cavallium.dbengine.database;
|
package it.cavallium.dbengine.database;
|
||||||
|
|
||||||
public sealed interface LLIndexRequest permits LLUpdateDocument, LLUpdateFields {}
|
public sealed interface LLIndexRequest permits LLSoftUpdateDocument, LLUpdateDocument, LLUpdateFields {}
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
package it.cavallium.dbengine.database;
|
||||||
|
|
||||||
|
public record LLSoftUpdateDocument(LLItem[] items, LLItem[] softDeleteItems) implements LLIndexRequest {}
|
@ -127,8 +127,12 @@ public class LLUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Document toDocument(LLUpdateDocument document) {
|
public static Document toDocument(LLUpdateDocument document) {
|
||||||
|
return toDocument(document.items());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Document toDocument(LLItem[] document) {
|
||||||
Document d = new Document();
|
Document d = new Document();
|
||||||
for (LLItem item : document.items()) {
|
for (LLItem item : document) {
|
||||||
d.add(LLUtils.toField(item));
|
d.add(LLUtils.toField(item));
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
|
@ -12,6 +12,7 @@ import it.cavallium.dbengine.client.LuceneOptions;
|
|||||||
import it.cavallium.dbengine.client.NRTCachingOptions;
|
import it.cavallium.dbengine.client.NRTCachingOptions;
|
||||||
import it.cavallium.dbengine.client.query.current.data.QueryParams;
|
import it.cavallium.dbengine.client.query.current.data.QueryParams;
|
||||||
import it.cavallium.dbengine.database.LLIndexRequest;
|
import it.cavallium.dbengine.database.LLIndexRequest;
|
||||||
|
import it.cavallium.dbengine.database.LLSoftUpdateDocument;
|
||||||
import it.cavallium.dbengine.database.LLUpdateDocument;
|
import it.cavallium.dbengine.database.LLUpdateDocument;
|
||||||
import it.cavallium.dbengine.database.LLItem;
|
import it.cavallium.dbengine.database.LLItem;
|
||||||
import it.cavallium.dbengine.database.LLLuceneIndex;
|
import it.cavallium.dbengine.database.LLLuceneIndex;
|
||||||
@ -319,6 +320,11 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
|||||||
.<Void>runSafe(() -> {
|
.<Void>runSafe(() -> {
|
||||||
if (request instanceof LLUpdateDocument updateDocument) {
|
if (request instanceof LLUpdateDocument updateDocument) {
|
||||||
indexWriter.updateDocument(LLUtils.toTerm(id), LLUtils.toDocument(updateDocument));
|
indexWriter.updateDocument(LLUtils.toTerm(id), LLUtils.toDocument(updateDocument));
|
||||||
|
} else if (request instanceof LLSoftUpdateDocument softUpdateDocument) {
|
||||||
|
indexWriter.softUpdateDocument(LLUtils.toTerm(id),
|
||||||
|
LLUtils.toDocument(softUpdateDocument.items()),
|
||||||
|
LLUtils.toFields(softUpdateDocument.softDeleteItems())
|
||||||
|
);
|
||||||
} else if (request instanceof LLUpdateFields updateFields) {
|
} else if (request instanceof LLUpdateFields updateFields) {
|
||||||
indexWriter.updateDocValues(LLUtils.toTerm(id), LLUtils.toFields(updateFields.items()));
|
indexWriter.updateDocValues(LLUtils.toTerm(id), LLUtils.toFields(updateFields.items()));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user