Skip to content

Commit 1716ac8

Browse files
authored
feat: add attribute at search (#1676)
1 parent f3bb65b commit 1716ac8

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/types/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export type SearchParams = Query &
128128
rankingScoreThreshold?: number;
129129
attributesToSearchOn?: string[] | null;
130130
hybrid?: HybridSearch;
131+
distinct?: string;
131132
};
132133

133134
// Search parameters for searches made with the GET method
@@ -148,6 +149,7 @@ export type SearchRequestGET = Pagination &
148149
hybridEmbedder?: string;
149150
hybridSemanticRatio?: number;
150151
rankingScoreThreshold?: number;
152+
distinct?: string;
151153
};
152154

153155
export type MultiSearchQuery = SearchParams & { indexUid: string };

tests/get_search.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,15 @@ describe.each([
511511
expect(response2.hits.length).toBeLessThanOrEqual(0);
512512
});
513513

514+
test(`${permission} key: search with distinct`, async () => {
515+
const client = await getClient(permission);
516+
const response = await client
517+
.index(index.uid)
518+
.search('', { distinct: 'genre' });
519+
520+
expect(response.hits.length).toEqual(4);
521+
});
522+
514523
test(`${permission} key: Try to search on deleted index and fail`, async () => {
515524
const client = await getClient(permission);
516525
const masterClient = await getClient('Master');

tests/search.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,15 @@ describe.each([
911911
expect(response).not.toHaveProperty('semanticHitCount');
912912
});
913913

914+
test(`${permission} key: search with distinct`, async () => {
915+
const client = await getClient(permission);
916+
const response = await client
917+
.index(index.uid)
918+
.search('', { distinct: 'genre' });
919+
920+
expect(response.hits.length).toEqual(4);
921+
});
922+
914923
test(`${permission} key: Try to search on deleted index and fail`, async () => {
915924
const client = await getClient(permission);
916925
const masterClient = await getClient('Master');

0 commit comments

Comments
 (0)