Skip to content

Commit 1d6507e

Browse files
Add frequency matching strategy (#1670)
* add frequency matching strategy * Update tests/search.test.ts --------- Co-authored-by: Clémentine <[email protected]>
1 parent dd8272c commit 1d6507e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export type IndexesResults<T> = ResourceResults<T> & {};
6363
export const MatchingStrategies = {
6464
ALL: 'all',
6565
LAST: 'last',
66+
FREQUENCY: 'frequency',
6667
} as const;
6768

6869
export type MatchingStrategies =

tests/search.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,18 @@ describe.each([
191191
expect(response.hits.length).toEqual(2);
192192
});
193193

194+
test(`${permission} key: Basic phrase search with matchingStrategy at FREQUENCY`, async () => {
195+
const client = await getClient(permission);
196+
const response = await client.index(index.uid).search('french book', {
197+
matchingStrategy: MatchingStrategies.FREQUENCY,
198+
});
199+
200+
expect(response).toHaveProperty('hits', expect.any(Array));
201+
expect(response).toHaveProperty('offset', 0);
202+
expect(response).toHaveProperty('limit', 20);
203+
expect(response.hits.length).toEqual(2);
204+
});
205+
194206
test(`${permission} key: Search with query in searchParams overwriting query`, async () => {
195207
const client = await getClient(permission);
196208
const response = await client

0 commit comments

Comments
 (0)