Skip to content

Commit b6f84af

Browse files
committed
add frequency matching strategy
1 parent 7b2054d commit b6f84af

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

.code-samples.meilisearch.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ search_parameter_guide_matching_strategy_2: |-
363363
client.index('movies').search('big fat liar', {
364364
matchingStrategy: 'all'
365365
})
366+
search_parameter_guide_matching_strategy_3: |-
367+
client.index('movies').search('big fat liar', {
368+
matchingStrategy: 'frequency'
369+
})
366370
search_parameter_guide_hitsperpage_1: |-
367371
client.index('movies').search('', {
368372
hitsPerPage: 15

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
197+
.index(index.uid)
198+
.search('french book', { matchingStrategy: MatchingStrategies.FREQUENCY });
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)