Skip to content

Commit 6a9151e

Browse files
committed
Add tests for bm25 + groupby
1 parent 3bd1e92 commit 6a9151e

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/graphql/getter.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,21 @@ describe('bm25 valid searchers', () => {
12891289

12901290
expect(mockClient.query).toHaveBeenCalledWith(expectedQuery);
12911291
});
1292+
1293+
test('query and groupby', () => {
1294+
const expectedQuery = `{Get{Person(bm25:{query:"accountant"},groupBy:{path:["employer"],groups:2,objectsPerGroup:3}){name}}}`;
1295+
1296+
new Getter(mockClient)
1297+
.withClassName('Person')
1298+
.withFields('name')
1299+
.withBm25({
1300+
query: 'accountant',
1301+
})
1302+
.withGroupBy({ path: ['employer'], groups: 2, objectsPerGroup: 3 })
1303+
.do();
1304+
1305+
expect(mockClient.query).toHaveBeenCalledWith(expectedQuery);
1306+
});
12921307
});
12931308

12941309
describe('hybrid valid searchers', () => {

src/graphql/journey.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,26 @@ describe('the graphql journey', () => {
311311
});
312312
});
313313

314+
test('graphql get bm25 with query and groupby', () => {
315+
return client.graphql
316+
.get()
317+
.withClassName('Article')
318+
.withBm25({ query: 'Apple' })
319+
.withGroupBy({
320+
path: ['title'],
321+
objectsPerGroup: 1,
322+
groups: 1,
323+
})
324+
.withFields('_additional { id }')
325+
.do()
326+
.then((res: any) => {
327+
expect(res.data.Get.Article.length).toBe(1);
328+
})
329+
.catch((e: any) => {
330+
throw new Error('it should not have errord' + e);
331+
});
332+
});
333+
314334
test('graphql get nearText with autocut', () => {
315335
return client.graphql
316336
.get()

0 commit comments

Comments
 (0)