Skip to content

Commit

Permalink
First implementation - But exactSearch uses the default VectorScorers…
Browse files Browse the repository at this point in the history
…, which are not using the original source
  • Loading branch information
carlosdelest committed Nov 6, 2024
1 parent 3a65731 commit 463e64d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected TopDocs approximateSearch(
return topDocs;
}

BitSet exactSearchAcceptDocs = topDocsToBitSet(topDocs, acceptDocs.length());
BitSet exactSearchAcceptDocs = topDocsToBitSet(topDocs, context.reader().maxDoc());
BitSetIterator bitSetIterator = new BitSetIterator(exactSearchAcceptDocs, topDocs.scoreDocs.length);
QueryTimeout queryTimeout = null;
if (knnCollectorManager instanceof TimeLimitingKnnCollectorManager timeLimitingKnnCollectorManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class KnnVectorQueryBuilder extends AbstractQueryBuilder<KnnVectorQueryBu
(Integer) args[2],
(Integer) args[3],
(Float) args[4],
(Float) args[5]
(Float) args[6]
)
);

Expand All @@ -102,14 +102,14 @@ public class KnnVectorQueryBuilder extends AbstractQueryBuilder<KnnVectorQueryBu
(p, c, n) -> p.namedObject(QueryVectorBuilder.class, n, c),
QUERY_VECTOR_BUILDER_FIELD
);
PARSER.declareFloat(optionalConstructorArg(), RESCORE_VECTOR_OVERSAMPLE);
PARSER.declareFieldArray(
KnnVectorQueryBuilder::addFilterQueries,
(p, c) -> AbstractQueryBuilder.parseTopLevelQuery(p),
FILTER_FIELD,
ObjectParser.ValueType.OBJECT_ARRAY
);
declareStandardFields(PARSER);
PARSER.declareFloat(optionalConstructorArg(), RESCORE_VECTOR_OVERSAMPLE);
}

public static KnnVectorQueryBuilder fromXContent(XContentParser parser) {
Expand All @@ -127,7 +127,7 @@ public static KnnVectorQueryBuilder fromXContent(XContentParser parser) {
private final Float rescoreOversample;

public KnnVectorQueryBuilder(String fieldName, float[] queryVector, Integer k, Integer numCands, Float vectorSimilarity) {
this(fieldName, VectorData.fromFloats(queryVector), null, null, k, numCands, vectorSimilarity);
this(fieldName, VectorData.fromFloats(queryVector), null, null, k, numCands, vectorSimilarity, null);
}

public KnnVectorQueryBuilder(
Expand All @@ -137,7 +137,7 @@ public KnnVectorQueryBuilder(
Integer numCands,
Float vectorSimilarity
) {
this(fieldName, null, queryVectorBuilder, null, k, numCands, vectorSimilarity);
this(fieldName, null, queryVectorBuilder, null, k, numCands, vectorSimilarity, null);
}

public KnnVectorQueryBuilder(String fieldName, byte[] queryVector, Integer k, Integer numCands, Float vectorSimilarity) {
Expand All @@ -157,7 +157,7 @@ private KnnVectorQueryBuilder(
Integer numCands,
Float vectorSimilarity
) {
this(fieldName, queryVector, null, null, k, numCands, vectorSimilarity, 0F);
this(fieldName, queryVector, null, null, k, numCands, vectorSimilarity, null);
}

private KnnVectorQueryBuilder(
Expand Down

0 comments on commit 463e64d

Please sign in to comment.