Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void initRocksDbOptions() {
if (this.rocksDBOptions == null || this.rocksDBOptions.isClosed()) {
LOGGER.info("rocksdb optionClass {}", optionClass);
try {
this.rocksDBOptions = (IRocksDBOptions) Class.forName(optionClass).newInstance();
this.rocksDBOptions = (IRocksDBOptions) Class.forName(optionClass).getDeclaredConstructor().newInstance();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do all implementation classes of optionClass have a no-argument constructor?
If some classes do not have a no-argument constructor, will getDeclaredConstructor() throw an exception?

this.rocksDBOptions.init(config);
} catch (Throwable e) {
LOGGER.error("{} not found", optionClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.KnnVectorField;
import org.apache.lucene.document.KnnFloatVectorField;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.KnnVectorQuery;
import org.apache.lucene.search.KnnFloatVectorQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.ByteBuffersDirectory;
import org.apache.lucene.store.Directory;
Expand Down Expand Up @@ -107,7 +107,7 @@ public void addVectorIndex(boolean isVertex, K key, String fieldName, float[] ve
}

// Add vector field
doc.add(new KnnVectorField(fieldName, vector));
doc.add(new KnnFloatVectorField(fieldName, vector));

// Add document to index
writer.addDocument(doc);
Expand Down Expand Up @@ -142,12 +142,12 @@ public K searchVectorIndex(boolean isVertex, String fieldName, float[] vector, i
IndexSearcher searcher = new IndexSearcher(reader);

// Create KNN vector query
KnnVectorQuery knnQuery = new KnnVectorQuery(fieldName, vector, topK);
KnnFloatVectorQuery knnQuery = new KnnFloatVectorQuery(fieldName, vector, topK);

// Execute search
TopDocs topDocs = searcher.search(knnQuery, topK);

Document firstDoc = searcher.doc(topDocs.scoreDocs[0].doc);
Document firstDoc = searcher.storedFields().document(topDocs.scoreDocs[0].doc);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the version requirements for Lucene regarding the storedFields() method? Does this change affect performance (by adding an extra method call)?


K result;
if (keyClass == String.class) {
Expand Down
Loading