Skip to content

Commit a225e29

Browse files
authored
Add bm25Operator to aggregate hybrid args type (#337)
1 parent 5ca5337 commit a225e29

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/collections/aggregate/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { WeaviateInvalidInputError, WeaviateQueryError } from '../../errors.js';
99
import { Aggregator } from '../../graphql/index.js';
1010
import { PrimitiveKeys, toBase64FromMedia } from '../../index.js';
1111
import { Deserialize } from '../deserialize/index.js';
12-
import { Bm25QueryProperty, NearVectorInputType, TargetVector } from '../query/types.js';
12+
import { Bm25OperatorOptions, Bm25QueryProperty, NearVectorInputType, TargetVector } from '../query/types.js';
1313
import { NearVectorInputGuards } from '../query/utils.js';
1414
import { Serialize } from '../serialize/index.js';
1515

@@ -45,6 +45,7 @@ export type AggregateHybridOptions<T, M, V> = AggregateBaseOptions<M> & {
4545
queryProperties?: (PrimitiveKeys<T> | Bm25QueryProperty<T>)[];
4646
targetVector?: TargetVector<V>;
4747
vector?: number[];
48+
bm25Operator?: Bm25OperatorOptions;
4849
};
4950

5051
export type AggregateGroupByHybridOptions<T, M, V> = AggregateHybridOptions<T, M, V> & {

src/collections/aggregate/integration.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable @typescript-eslint/no-non-null-assertion */
22
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
3+
import { requireAtLeast } from '../../../test/version.js';
34
import { WeaviateQueryError, WeaviateUnsupportedFeatureError } from '../../errors.js';
4-
import weaviate, { AggregateText, WeaviateClient } from '../../index.js';
5+
import weaviate, { AggregateText, Bm25Operator, WeaviateClient } from '../../index.js';
56
import { Collection } from '../collection/index.js';
67
import { CrossReference } from '../references/index.js';
78
import { DataObject } from '../types/index.js';
@@ -448,6 +449,16 @@ describe('Testing of collection.aggregate search methods', () => {
448449
expect(result.totalCount).toBeGreaterThan(0);
449450
});
450451

452+
requireAtLeast(1, 31, 0).it('bm25 search operator with hybrid', async () => {
453+
const result = await collection.aggregate.hybrid('test', {
454+
bm25Operator: Bm25Operator.and(),
455+
maxVectorDistance: 1,
456+
queryProperties: ['text'],
457+
returnMetrics: collection.metrics.aggregate('text').text(['count']),
458+
});
459+
expect(result.totalCount).toBeGreaterThan(0);
460+
});
461+
451462
it('should return a grouped aggregation on a hybrid search', async () => {
452463
if (await client.getWeaviateVersion().then((ver) => ver.isLowerThan(1, 25, 0))) {
453464
console.warn('Skipping test as there is a bug with this in 1.24.26 that will not be fixed');

0 commit comments

Comments
 (0)