Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to prefix the search engine's objectID ? #61

Open
philohelp opened this issue Feb 3, 2022 · 2 comments
Open

Possibility to prefix the search engine's objectID ? #61

philohelp opened this issue Feb 3, 2022 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@philohelp
Copy link

philohelp commented Feb 3, 2022

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.

@MattieBelt
Copy link
Owner

MattieBelt commented Feb 4, 2022

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. 💪🏼

@MattieBelt MattieBelt added the documentation Improvements or additions to documentation label Feb 4, 2022
@MattieBelt MattieBelt self-assigned this Feb 4, 2022
@philohelp
Copy link
Author

Huge thanks, this is amazing and exactly what I needed !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants