As per the documentation, the transformer function give you more control over what to be indexed.
documentation
๐
The transformer function in the MeiliSearch settings is an optional function that accepts a product as a parameter and returns an object to be indexed. This allows you to have more control over what you're indexing. For example, you can add details related to variants or custom relations, or you can filter out certain products.
here is my transformer function to send created_at as timestamp, but it is not working. Actually the transformer function does not even run, which I have checked it through the console log.
settings: {
campaigns: {
indexSettings: {
searchableAttributes: [
"title",
"description",
"handle",
],
displayedAttributes: [
"title",
"description",
"id",
"images",
"handle",
"campaign_target",
"deadline",
"is_active",
"organizers",
"raised_amount",
"created_at",
],
filterableAttributes: ["created_at", "deadline"],
},
primaryKey: "id",
transformer: (campaign) => (
{
created_at: new Date(campaign.created_at).getTime(),
deadline: new Date(campaign.deadline).getTime(),
}
)
},
}
I 've gone through each step of setting the plugin up, and there was nothing I was missing, and here is my code for plugin setting.
For the moment for I have just found a way around it, I am transforming data just before it is sent to Meilisearch. Here is the code for that