Skip to content

Commit

Permalink
Add sort order for facet values for Meilisearch v1.3 (#1536)
Browse files Browse the repository at this point in the history
* Add sort order for facet values for Meilisearch v1.3

* Change type casting of the settings object in settings tests
  • Loading branch information
bidoubiwa authored Jul 10, 2023
1 parent 15c183c commit 4338c47
Show file tree
Hide file tree
Showing 5 changed files with 875 additions and 130 deletions.
4 changes: 4 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,13 @@ export type TypoTolerance = {
}
} | null

export type FacetOrder = 'alpha' | 'count'

export type Faceting = {
maxValuesPerFacet?: number | null
sortFacetValuesBy?: Record<string, FacetOrder> | null
}

export type PaginationSettings = {
maxTotalHits?: number | null
}
Expand Down
75 changes: 75 additions & 0 deletions tests/__snapshots__/faceting.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Test on faceting Admin key: Get default faceting object 1`] = `
Object {
"maxValuesPerFacet": 100,
"sortFacetValuesBy": Object {
"*": "alpha",
},
}
`;

exports[`Test on faceting Admin key: Reset faceting 1`] = `
Object {
"maxValuesPerFacet": 100,
"sortFacetValuesBy": Object {
"*": "alpha",
},
}
`;

exports[`Test on faceting Admin key: Update faceting at null 1`] = `
Object {
"maxValuesPerFacet": 100,
"sortFacetValuesBy": Object {
"*": "alpha",
},
}
`;

exports[`Test on faceting Admin key: Update faceting settings 1`] = `
Object {
"maxValuesPerFacet": 12,
"sortFacetValuesBy": Object {
"*": "alpha",
"test": "count",
},
}
`;

exports[`Test on faceting Master key: Get default faceting object 1`] = `
Object {
"maxValuesPerFacet": 100,
"sortFacetValuesBy": Object {
"*": "alpha",
},
}
`;

exports[`Test on faceting Master key: Reset faceting 1`] = `
Object {
"maxValuesPerFacet": 100,
"sortFacetValuesBy": Object {
"*": "alpha",
},
}
`;

exports[`Test on faceting Master key: Update faceting at null 1`] = `
Object {
"maxValuesPerFacet": 100,
"sortFacetValuesBy": Object {
"*": "alpha",
},
}
`;

exports[`Test on faceting Master key: Update faceting settings 1`] = `
Object {
"maxValuesPerFacet": 12,
"sortFacetValuesBy": Object {
"*": "alpha",
"test": "count",
},
}
`;
Loading

0 comments on commit 4338c47

Please sign in to comment.