diff --git a/src/collections/aggregate/index.ts b/src/collections/aggregate/index.ts index a4cce65e..9060ad8d 100644 --- a/src/collections/aggregate/index.ts +++ b/src/collections/aggregate/index.ts @@ -9,7 +9,7 @@ import { WeaviateInvalidInputError, WeaviateQueryError } from '../../errors.js'; import { Aggregator } from '../../graphql/index.js'; import { PrimitiveKeys, toBase64FromMedia } from '../../index.js'; import { Deserialize } from '../deserialize/index.js'; -import { Bm25QueryProperty, NearVectorInputType, TargetVector } from '../query/types.js'; +import { Bm25OperatorOptions, Bm25QueryProperty, NearVectorInputType, TargetVector } from '../query/types.js'; import { NearVectorInputGuards } from '../query/utils.js'; import { Serialize } from '../serialize/index.js'; @@ -45,6 +45,7 @@ export type AggregateHybridOptions = AggregateBaseOptions & { queryProperties?: (PrimitiveKeys | Bm25QueryProperty)[]; targetVector?: TargetVector; vector?: number[]; + bm25Operator?: Bm25OperatorOptions; }; export type AggregateGroupByHybridOptions = AggregateHybridOptions & { diff --git a/src/collections/aggregate/integration.test.ts b/src/collections/aggregate/integration.test.ts index cd64d09a..df4cc30e 100644 --- a/src/collections/aggregate/integration.test.ts +++ b/src/collections/aggregate/integration.test.ts @@ -1,7 +1,8 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */ +import { requireAtLeast } from '../../../test/version.js'; import { WeaviateQueryError, WeaviateUnsupportedFeatureError } from '../../errors.js'; -import weaviate, { AggregateText, WeaviateClient } from '../../index.js'; +import weaviate, { AggregateText, Bm25Operator, WeaviateClient } from '../../index.js'; import { Collection } from '../collection/index.js'; import { CrossReference } from '../references/index.js'; import { DataObject } from '../types/index.js'; @@ -448,6 +449,16 @@ describe('Testing of collection.aggregate search methods', () => { expect(result.totalCount).toBeGreaterThan(0); }); + requireAtLeast(1, 31, 0).it('bm25 search operator with hybrid', async () => { + const result = await collection.aggregate.hybrid('test', { + bm25Operator: Bm25Operator.and(), + maxVectorDistance: 1, + queryProperties: ['text'], + returnMetrics: collection.metrics.aggregate('text').text(['count']), + }); + expect(result.totalCount).toBeGreaterThan(0); + }); + it('should return a grouped aggregation on a hybrid search', async () => { if (await client.getWeaviateVersion().then((ver) => ver.isLowerThan(1, 25, 0))) { console.warn('Skipping test as there is a bug with this in 1.24.26 that will not be fixed');