Specified primaryKey to avoid problems with videos + filterable categories for libraryitem
This commit is contained in:
parent
5a802b6347
commit
300752e684
|
@ -18,6 +18,7 @@ export interface MeiliLibraryItem extends LibraryItemAttributesFragment {
|
|||
sortable_name: string;
|
||||
sortable_price: number | undefined;
|
||||
sortable_date: number | undefined;
|
||||
filterable_categories: string[];
|
||||
untangible_group_item: boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,9 @@ const transformLibraryItem: TransformFunction<MeiliIndices.LIBRARY_ITEM> = (data
|
|||
attributes.price?.currency?.data?.attributes && isDefined(attributes.price.amount)
|
||||
? attributes.price.amount * attributes.price.currency.data.attributes.rate_to_usd
|
||||
: undefined,
|
||||
filterable_categories: filterHasAttributes(attributes.categories?.data, [
|
||||
"attributes.short",
|
||||
] as const).map((category) => category.attributes.short),
|
||||
untangible_group_item: isUntangibleGroupItem(attributes.metadata?.[0]),
|
||||
...attributes,
|
||||
};
|
||||
|
|
|
@ -8,7 +8,6 @@ export const synchronizeStrapiAndMeili = async (): Promise<void> => {
|
|||
const indexes = await meili.getIndexes();
|
||||
await Promise.all(indexes.results.map(async (index) => index.delete()));
|
||||
|
||||
|
||||
// [ LIBRARY ITEMS ]
|
||||
|
||||
const libraryItems = await sdk.getLibraryItems();
|
||||
|
@ -19,7 +18,7 @@ export const synchronizeStrapiAndMeili = async (): Promise<void> => {
|
|||
),
|
||||
["title", "subtitle", "descriptions"],
|
||||
["sortable_name", "sortable_date", "sortable_price"],
|
||||
["primary", "root_item", "id", "untangible_group_item"]
|
||||
["primary", "root_item", "id", "untangible_group_item", "filterable_categories"]
|
||||
);
|
||||
|
||||
// [ CONTENT ]
|
||||
|
@ -94,7 +93,7 @@ const processIndex = async <I extends MeiliDocumentsType["index"]>(
|
|||
const meili = getMeili();
|
||||
|
||||
if (data && data.length > 0) {
|
||||
await meili.createIndex(indexName);
|
||||
await meili.createIndex(indexName, { primaryKey: "id" });
|
||||
const index = meili.index(indexName);
|
||||
index.updateSettings({
|
||||
searchableAttributes: searchableAttributes as string[],
|
||||
|
|
Loading…
Reference in New Issue