Fix terms

This commit is contained in:
Andrea Cavalli 2022-03-15 11:46:00 +01:00
parent 93c5251392
commit 4cc8d44fd8
4 changed files with 19 additions and 5 deletions

View File

@ -144,6 +144,14 @@ public class LLItem {
}
}
public static LLItem newStringField(String name, BytesRef bytesRef, Field.Store store) {
if (store == Field.Store.YES) {
return new LLItem(LLType.StringFieldStored, name, bytesRef);
} else {
return new LLItem(LLType.StringField, name, bytesRef);
}
}
public static LLItem newSortedNumericDocValuesField(String name, long data) {
return new LLItem(LLType.SortedNumericDocValuesField, name, data);
}

View File

@ -7,4 +7,4 @@ import org.apache.lucene.util.BytesRef;
import org.jetbrains.annotations.Nullable;
import reactor.core.publisher.Mono;
public record LLKeyScore(int docId, float score, @Nullable IndexableField key) {}
public record LLKeyScore(int docId, int shardId, float score, @Nullable IndexableField key) {}

View File

@ -224,7 +224,13 @@ public class LLUtils {
case SortedNumericDocValuesField -> new SortedNumericDocValuesField(item.getName(), item.longData());
case NumericDocValuesField -> new NumericDocValuesField(item.getName(), item.longData());
case StringField -> new StringField(item.getName(), item.stringValue(), Store.NO);
case StringFieldStored -> new StringField(item.getName(), item.stringValue(), Store.YES);
case StringFieldStored -> {
if (item.getData() instanceof BytesRef bytesRef) {
yield new StringField(item.getName(), bytesRef, Store.YES);
} else {
yield new StringField(item.getName(), item.stringValue(), Store.YES);
}
}
};
}
@ -259,7 +265,7 @@ public class LLUtils {
}
public static it.cavallium.dbengine.database.LLKeyScore toKeyScore(LLKeyScore hit) {
return new it.cavallium.dbengine.database.LLKeyScore(hit.docId(), hit.score(), hit.key());
return new it.cavallium.dbengine.database.LLKeyScore(hit.docId(), hit.shardId(), hit.score(), hit.key());
}
public static String toStringSafe(@Nullable Buffer key) {

View File

@ -419,13 +419,13 @@ public class LuceneUtils {
} else {
collectedDoc = null;
}
return new LLKeyScore(shardDocId, score, collectedDoc);
return new LLKeyScore(shardDocId, shardIndex, score, collectedDoc);
} catch (NoSuchElementException ex) {
logger.debug("Error: document {} key is not present!", shardDocId);
return null;
} catch (Exception ex) {
logger.error("Failed to read document {}", shardDocId, ex);
return new LLKeyScore(shardDocId, score, null);
return new LLKeyScore(shardDocId, shardIndex, score, null);
}
}