Skip to content

Set searchableAttributes without API/cURL – via code? #1039

@aloneinthecityy

Description

@aloneinthecityy

I have a corporate/institutional website with a blog, and we use Strapi as the CMS for the blog.

For indexed search on the website, we use the Meilisearch plugin for Strapi, along with InstantSearch (a front-end tool for Meilisearch).

Everything works fine until someone updates a blog post — when that happens, the Meilisearch index in Strapi is updated as expected. So far, so good.

However, after every update, we have to manually re-define the filterableAttributes and searchableAttributes via cURL (using Postman or Insomnia).

Otherwise, InstantSearch/Meilisearch stops working properly.

I initially tried defining the attributes in /config/plugins.js like this:

module.exports = ({ env }) => ({
meilisearch: {
config: {
host: "**",
apiKey: "*",
"blog-post": {
settings: {
filterableAttributes: [
"category.name",
"tipo.name",
"tags.tag_nome",
"category.slug",
"tags.slug",
],
sortableAttributes: ["updatedAt"],
rankingRules: [
"words",
"typo",
"proximity",
"attribute",
"sort",
"exactness",
],
},
},
"library-post": {
settings: {
filterableAttributes: [
"category.name",
"tipo.name",
"tags.tag_nome",
"category.slug",
"tags.slug",
],
sortableAttributes: ["updatedAt"],
rankingRules: [
"words",
"typo",
"proximity",
"attribute",
"sort",
"exactness",
],
},
},
},
},
});
But it doesn’t seem to work. Even with these settings in place, I still need to define the attributes manually using cURL.

Is there a way to set these attributes automatically (without using cURL or external API calls)?

Any help would be greatly appreciated!

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededneeds investigationNeeds to take time to understand the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions