Skip to content

Commit a254718

Browse files
authored
Merge pull request #245 from weaviate/#198/add-max-vector-distance-to-query
Add new vectorDistance param to hybrid query
2 parents 3164cfd + 04d9467 commit a254718

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/collections/query/types.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ export type Bm25Options<T> = BaseBm25Options<T> | GroupByBm25Options<T> | undefi
103103
export type BaseHybridOptions<T> = SearchOptions<T> & {
104104
/** The weight of the BM25 score. If not specified, the default weight specified by the server is used. */
105105
alpha?: number;
106-
/** The specific vector to search for or a specific vector subsearch. If not specified, the query is vectorized and used in the similarity search. */
107-
vector?: NearVectorInputType | HybridNearTextSubSearch | HybridNearVectorSubSearch;
108-
/** The properties to search in. If not specified, all properties are searched. */
109-
queryProperties?: (PrimitiveKeys<T> | Bm25QueryProperty<T>)[];
110106
/** The type of fusion to apply. If not specified, the default fusion type specified by the server is used. */
111107
fusionType?: 'Ranked' | 'RelativeScore';
108+
/** The maximum tolerated similarity in the vector search before the results are cutoff from the result set. */
109+
maxVectorDistance?: number;
110+
/** The properties to search in. If not specified, all properties are searched. */
111+
queryProperties?: (PrimitiveKeys<T> | Bm25QueryProperty<T>)[];
112112
/** Specify which vector(s) to search on if using named vectors. */
113113
targetVector?: TargetVectorInputType;
114+
/** The specific vector to search for or a specific vector subsearch. If not specified, the query is vectorized and used in the similarity search. */
115+
vector?: NearVectorInputType | HybridNearTextSubSearch | HybridNearVectorSubSearch;
114116
};
115117

116118
export type HybridSubSearchBase = {

src/collections/serialize/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ export class Serialize {
519519
alpha: args.alpha ? args.alpha : 0.5,
520520
properties: this.bm25QueryProperties(args.queryProperties),
521521
vectorBytes: vectorBytes,
522+
vectorDistance: args.maxVectorDistance,
522523
fusionType: fusionType(args.fusionType),
523524
targetVectors,
524525
targets,

src/collections/serialize/unit.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ describe('Unit testing of Serialize', () => {
154154
vector: [1, 2, 3],
155155
targetVector: 'title',
156156
fusionType: 'Ranked',
157+
maxVectorDistance: 0.4,
157158
supportsTargets: false,
158159
supportsVectorsForTargets: false,
159160
supportsWeightsForTargets: false,
@@ -166,6 +167,7 @@ describe('Unit testing of Serialize', () => {
166167
vectorBytes: new Uint8Array(new Float32Array([1, 2, 3]).buffer),
167168
targetVectors: ['title'],
168169
fusionType: Hybrid_FusionType.FUSION_TYPE_RANKED,
170+
vectorDistance: 0.4,
169171
}),
170172
metadata: MetadataRequest.fromPartial({ uuid: true }),
171173
});

0 commit comments

Comments
 (0)