diff --git a/src/collections/query/types.ts b/src/collections/query/types.ts index 83080d21..b3954c39 100644 --- a/src/collections/query/types.ts +++ b/src/collections/query/types.ts @@ -103,14 +103,16 @@ export type Bm25Options = BaseBm25Options | GroupByBm25Options | undefi export type BaseHybridOptions = SearchOptions & { /** The weight of the BM25 score. If not specified, the default weight specified by the server is used. */ alpha?: number; - /** The specific vector to search for or a specific vector subsearch. If not specified, the query is vectorized and used in the similarity search. */ - vector?: NearVectorInputType | HybridNearTextSubSearch | HybridNearVectorSubSearch; - /** The properties to search in. If not specified, all properties are searched. */ - queryProperties?: (PrimitiveKeys | Bm25QueryProperty)[]; /** The type of fusion to apply. If not specified, the default fusion type specified by the server is used. */ fusionType?: 'Ranked' | 'RelativeScore'; + /** The maximum tolerated similarity in the vector search before the results are cutoff from the result set. */ + maxVectorDistance?: number; + /** The properties to search in. If not specified, all properties are searched. */ + queryProperties?: (PrimitiveKeys | Bm25QueryProperty)[]; /** Specify which vector(s) to search on if using named vectors. */ targetVector?: TargetVectorInputType; + /** The specific vector to search for or a specific vector subsearch. If not specified, the query is vectorized and used in the similarity search. */ + vector?: NearVectorInputType | HybridNearTextSubSearch | HybridNearVectorSubSearch; }; export type HybridSubSearchBase = { diff --git a/src/collections/serialize/index.ts b/src/collections/serialize/index.ts index e8aa3f3d..b10d40f5 100644 --- a/src/collections/serialize/index.ts +++ b/src/collections/serialize/index.ts @@ -519,6 +519,7 @@ export class Serialize { alpha: args.alpha ? args.alpha : 0.5, properties: this.bm25QueryProperties(args.queryProperties), vectorBytes: vectorBytes, + vectorDistance: args.maxVectorDistance, fusionType: fusionType(args.fusionType), targetVectors, targets, diff --git a/src/collections/serialize/unit.test.ts b/src/collections/serialize/unit.test.ts index 4b3eae72..2b77505e 100644 --- a/src/collections/serialize/unit.test.ts +++ b/src/collections/serialize/unit.test.ts @@ -154,6 +154,7 @@ describe('Unit testing of Serialize', () => { vector: [1, 2, 3], targetVector: 'title', fusionType: 'Ranked', + maxVectorDistance: 0.4, supportsTargets: false, supportsVectorsForTargets: false, supportsWeightsForTargets: false, @@ -166,6 +167,7 @@ describe('Unit testing of Serialize', () => { vectorBytes: new Uint8Array(new Float32Array([1, 2, 3]).buffer), targetVectors: ['title'], fusionType: Hybrid_FusionType.FUSION_TYPE_RANKED, + vectorDistance: 0.4, }), metadata: MetadataRequest.fromPartial({ uuid: true }), });