Skip to content

Commit

Permalink
add frequency matching strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
the-sinner committed Jun 10, 2024
1 parent 7b2054d commit b6f84af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ search_parameter_guide_matching_strategy_2: |-
client.index('movies').search('big fat liar', {
matchingStrategy: 'all'
})
search_parameter_guide_matching_strategy_3: |-
client.index('movies').search('big fat liar', {
matchingStrategy: 'frequency'
})
search_parameter_guide_hitsperpage_1: |-
client.index('movies').search('', {
hitsPerPage: 15
Expand Down
1 change: 1 addition & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type IndexesResults<T> = ResourceResults<T> & {};
export const MatchingStrategies = {
ALL: 'all',
LAST: 'last',
FREQUENCY: 'frequency',
} as const;

export type MatchingStrategies =
Expand Down
12 changes: 12 additions & 0 deletions tests/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ describe.each([
expect(response.hits.length).toEqual(2);
});

test(`${permission} key: Basic phrase search with matchingStrategy at FREQUENCY`, async () => {
const client = await getClient(permission);
const response = await client
.index(index.uid)
.search('french book', { matchingStrategy: MatchingStrategies.FREQUENCY });

expect(response).toHaveProperty('hits', expect.any(Array));
expect(response).toHaveProperty('offset', 0);
expect(response).toHaveProperty('limit', 20);
expect(response.hits.length).toEqual(2);
});

test(`${permission} key: Search with query in searchParams overwriting query`, async () => {
const client = await getClient(permission);
const response = await client
Expand Down

0 comments on commit b6f84af

Please sign in to comment.