Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LUCENE-9004: KNN vector search using NSW graphs #2022

Merged
merged 17 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions lucene/core/src/java/org/apache/lucene/codecs/VectorWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ public SearchStrategy searchStrategy() {
return subs.get(0).values.searchStrategy();
}

@Override
public TopDocs search(float[] target, int k, int fanout) throws IOException {
throw new UnsupportedOperationException();
}

class MergerRandomAccess implements VectorValues.RandomAccess {

private final List<RandomAccess> raSubs;
Expand Down Expand Up @@ -272,12 +277,6 @@ public float[] vectorValue(int target) throws IOException {
public BytesRef binaryValue(int targetOrd) throws IOException {
throw new UnsupportedOperationException();
}

@Override
public TopDocs search(float[] target, int k, int fanout) throws IOException {
throw new UnsupportedOperationException();
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.lucene.codecs.VectorWriter;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.index.SegmentWriteState;
import org.apache.lucene.index.VectorValues;

/**
* Lucene 9.0 vector format, which encodes dense numeric vector values.
msokolov marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -33,15 +34,16 @@ public final class Lucene90VectorFormat extends VectorFormat {

static final String META_CODEC_NAME = "Lucene90VectorFormatMeta";
static final String VECTOR_DATA_CODEC_NAME = "Lucene90VectorFormatData";

static final String VECTOR_INDEX_CODEC_NAME = "Lucene90VectorFormatIndex";
static final String META_EXTENSION = "vem";
static final String VECTOR_DATA_EXTENSION = "vec";
static final String VECTOR_INDEX_EXTENSION = "vex";

static final int VERSION_START = 0;
static final int VERSION_CURRENT = VERSION_START;

/** Sole constructor */
public Lucene90VectorFormat() {
Lucene90VectorFormat() {
msokolov marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
Expand All @@ -54,4 +56,10 @@ public VectorReader fieldsReader(SegmentReadState state) throws IOException {
return new Lucene90VectorReader(state);
}

static boolean isHnswStrategy(VectorValues.SearchStrategy searchStrategy) {
msokolov marked this conversation as resolved.
Show resolved Hide resolved
return searchStrategy == VectorValues.SearchStrategy.DOT_PRODUCT_HNSW ||
searchStrategy == VectorValues.SearchStrategy.EUCLIDEAN_HNSW;
}


msokolov marked this conversation as resolved.
Show resolved Hide resolved
}