Add numeric field
This commit is contained in:
parent
798b8a5288
commit
7047b512fc
@ -81,6 +81,10 @@ public class LLItem {
|
||||
return new LLItem(LLType.SortedNumericDocValuesField, name, data);
|
||||
}
|
||||
|
||||
public static LLItem newNumericDocValuesField(String name, long data) {
|
||||
return new LLItem(LLType.NumericDocValuesField, name, data);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package it.cavallium.dbengine.database;
|
||||
|
||||
/**
|
||||
* https://lucene.apache.org/core/8_0_0/core/org/apache/lucene/document/Field.html
|
||||
*/
|
||||
public enum LLType {
|
||||
StringField,
|
||||
StringFieldStored,
|
||||
@ -7,6 +10,7 @@ public enum LLType {
|
||||
LongPoint,
|
||||
LongStoredField,
|
||||
FloatPoint,
|
||||
NumericDocValuesField,
|
||||
SortedNumericDocValuesField,
|
||||
TextField,
|
||||
TextFieldStored
|
||||
|
@ -34,6 +34,7 @@ import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FloatPoint;
|
||||
import org.apache.lucene.document.IntPoint;
|
||||
import org.apache.lucene.document.LongPoint;
|
||||
import org.apache.lucene.document.NumericDocValuesField;
|
||||
import org.apache.lucene.document.SortedNumericDocValuesField;
|
||||
import org.apache.lucene.document.StoredField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
@ -179,9 +180,9 @@ public class LLUtils {
|
||||
case FloatPoint -> new FloatPoint(item.getName(), ByteBuffer.wrap(item.getData()).getFloat());
|
||||
case TextField -> new TextField(item.getName(), item.stringValue(), Field.Store.NO);
|
||||
case TextFieldStored -> new TextField(item.getName(), item.stringValue(), Field.Store.YES);
|
||||
case SortedNumericDocValuesField -> new SortedNumericDocValuesField(item.getName(),
|
||||
Longs.fromByteArray(item.getData())
|
||||
);
|
||||
case SortedNumericDocValuesField ->
|
||||
new SortedNumericDocValuesField(item.getName(), Longs.fromByteArray(item.getData()));
|
||||
case NumericDocValuesField -> new NumericDocValuesField(item.getName(), Longs.fromByteArray(item.getData()));
|
||||
case StringField -> new StringField(item.getName(), item.stringValue(), Field.Store.NO);
|
||||
case StringFieldStored -> new StringField(item.getName(), item.stringValue(), Field.Store.YES);
|
||||
};
|
||||
@ -491,7 +492,7 @@ public class LLUtils {
|
||||
* cleanup resource
|
||||
* @param cleanupOnSuccess if true the resource will be cleaned up if the function is successful
|
||||
*/
|
||||
public static <U, T extends Resource<T>, V extends T> Mono<U> usingResource(Mono<V> resourceSupplier,
|
||||
public static <U, T extends Resource<? extends T>, V extends T> Mono<U> usingResource(Mono<V> resourceSupplier,
|
||||
Function<V, Mono<U>> resourceClosure,
|
||||
boolean cleanupOnSuccess) {
|
||||
return Mono.usingWhen(resourceSupplier, resourceClosure, r -> {
|
||||
|
@ -28,13 +28,13 @@ public class StringIndicizer extends Indicizer<String, String> {
|
||||
var numInt = Ints.tryParse(value);
|
||||
if (numInt != null) {
|
||||
fields.add(LLItem.newIntPoint("intpoint", numInt));
|
||||
fields.add(LLItem.newSortedNumericDocValuesField("intsort", numInt));
|
||||
fields.add(LLItem.newNumericDocValuesField("intsort", numInt));
|
||||
}
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
var numLong = Longs.tryParse(value);
|
||||
if (numLong != null) {
|
||||
fields.add(LLItem.newLongPoint("longpoint", numLong));
|
||||
fields.add(LLItem.newSortedNumericDocValuesField("longsort", numLong));
|
||||
fields.add(LLItem.newNumericDocValuesField("longsort", numLong));
|
||||
}
|
||||
return new LLUpdateDocument(fields.toArray(LLItem[]::new));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user