mattie-strapi-bundle
mattie-strapi-bundle copied to clipboard
Possibility to prefix the search engine's objectID ?
Hi, thanks for the great job with this plugin. I was wandering if there could be a way to prefix the item's objectID stored on the search engine (in my case Algolia) because I have several different strapi models that I'd like to index on one single index on the search engine. Without the possibility to prefix the ObjectId (or to chose another unique field as id - i.e the entry's slug), entry with id:1 on a strapi model X will replace engine's entry with id:1 on a strapi model Y. Here is the use case: the website offers resources about jobs. Say the user wants to know about how to become a "movie producer". Some of the resources will be documents, some will be educationnal, some will be videos etc. The user should be able to query "I want to become a movie producer" and then to be presented all the different types of resources. As a workaround, once in the client, algolia's search on multiple indices appears pretty straightforward. But things seem to be a little more complicated when it comes to the auto-complete feature - hence the unique index. Would you consider this as bad practice ? Thanks in advance.
Hey @philohelp,
Thanks for submitting this issue. I have great news; It is already implemented, I just forgot to document this, it should have been included in the config table as well be part of the composite index config example. 😦
Property | Description | Type | Default value |
---|---|---|---|
contentTypes.prefix | Set a prefix on the entry id . |
String | '' |
module.exports = ({ env }) => ({
search: {
enabled: true,
config: {
// ..
contentTypes: [
{
name: 'api::podcast.podcast',
index: 'global-search',
prefix: 'podcast',
},
{
name: 'api::episode.episode',
index: 'global-search',
prefix: 'episode',
},
],
},
},
});
I'll push a fix for the docs shortly. 💪🏼
Huge thanks, this is amazing and exactly what I needed !