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_name: string;
|
||||||
sortable_price: number | undefined;
|
sortable_price: number | undefined;
|
||||||
sortable_date: number | undefined;
|
sortable_date: number | undefined;
|
||||||
|
filterable_categories: string[];
|
||||||
untangible_group_item: boolean;
|
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?.currency?.data?.attributes && isDefined(attributes.price.amount)
|
||||||
? attributes.price.amount * attributes.price.currency.data.attributes.rate_to_usd
|
? attributes.price.amount * attributes.price.currency.data.attributes.rate_to_usd
|
||||||
: undefined,
|
: undefined,
|
||||||
|
filterable_categories: filterHasAttributes(attributes.categories?.data, [
|
||||||
|
"attributes.short",
|
||||||
|
] as const).map((category) => category.attributes.short),
|
||||||
untangible_group_item: isUntangibleGroupItem(attributes.metadata?.[0]),
|
untangible_group_item: isUntangibleGroupItem(attributes.metadata?.[0]),
|
||||||
...attributes,
|
...attributes,
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,6 @@ export const synchronizeStrapiAndMeili = async (): Promise<void> => {
|
||||||
const meili = getMeili();
|
const meili = getMeili();
|
||||||
const indexes = await meili.getIndexes();
|
const indexes = await meili.getIndexes();
|
||||||
await Promise.all(indexes.results.map(async (index) => index.delete()));
|
await Promise.all(indexes.results.map(async (index) => index.delete()));
|
||||||
|
|
||||||
|
|
||||||
// [ LIBRARY ITEMS ]
|
// [ LIBRARY ITEMS ]
|
||||||
|
|
||||||
|
@ -19,7 +18,7 @@ export const synchronizeStrapiAndMeili = async (): Promise<void> => {
|
||||||
),
|
),
|
||||||
["title", "subtitle", "descriptions"],
|
["title", "subtitle", "descriptions"],
|
||||||
["sortable_name", "sortable_date", "sortable_price"],
|
["sortable_name", "sortable_date", "sortable_price"],
|
||||||
["primary", "root_item", "id", "untangible_group_item"]
|
["primary", "root_item", "id", "untangible_group_item", "filterable_categories"]
|
||||||
);
|
);
|
||||||
|
|
||||||
// [ CONTENT ]
|
// [ CONTENT ]
|
||||||
|
@ -94,7 +93,7 @@ const processIndex = async <I extends MeiliDocumentsType["index"]>(
|
||||||
const meili = getMeili();
|
const meili = getMeili();
|
||||||
|
|
||||||
if (data && data.length > 0) {
|
if (data && data.length > 0) {
|
||||||
await meili.createIndex(indexName);
|
await meili.createIndex(indexName, { primaryKey: "id" });
|
||||||
const index = meili.index(indexName);
|
const index = meili.index(indexName);
|
||||||
index.updateSettings({
|
index.updateSettings({
|
||||||
searchableAttributes: searchableAttributes as string[],
|
searchableAttributes: searchableAttributes as string[],
|
||||||
|
|
Loading…
Reference in New Issue