Search Plugin 1.0.0-alpha.1

Get started with fast content search by installing this Strapi Search Plugin! 🔍

Index your content
Configure each index and the fields
Search provider system
This plugin is still in development. 🚧

Installation

Add @mattie-bundle/strapi-plugin-search as dependency to your project with:

yarn add @mattie-bundle/strapi-plugin-search
npm install @mattie-bundle/strapi-plugin-search

After installing the plugin, rebuild your Strapi admin panel.

yarn build --clean
npm run build -- --clean

Configuration

File based

The plugin can be configured by file (./config/plugins.js). The file configuration uses the Strapi plugin configuration v4.

PropertyDescriptionTypeDefault value
providerName of the provider.String (required)
providerOptionsProvider specific options, checkout the provider configuration for the required options.Object
prefixSet a prefix on all indexes.Stringstrapi.config. environment + '_'
excludedFieldsFields that are not indexed on all indexes.Array<String>['created_by', 'updated_by']
debugEnable or disable the debug logs.Booleanfalse
contentTypesList op indexes content types.Array<Object>
contentTypes.nameUID of the content type.String (required)
contentTypes.indexName of the index.StringcontentTypes.name
contentTypes.fieldsFields that are indexed.Array<String>All fields.

Use yarn strapi content-types:list to list all existing content type UIDs with the Strapi CLI. v4

Configuration examples

./config/plugins.js
module.exports = ({ env }) => ({
  search: {
    enabled: true,
    config: {
      provider: 'algolia',
      providerOptions: {
        apiKey: env('ALGOLIA_PROVIDER_ADMIN_API_KEY'),
        applicationId: env('ALGOLIA_PROVIDER_APPLICATION_ID'),
      },
      contentTypes: [{ name: 'api::podcast.podcast' }, { name: 'api::episode.episode' }, { name: 'api::category.category' }],
    },
  },
});
./config/plugins.js
module.exports = ({ env }) => ({
  search: {
    enabled: true,
    config: {
      // ..
      contentTypes: [
        {
          name: 'api::podcast.podcast',
          index: 'global-search',
        },
        {
          name: 'api::episode.episode',
          index: 'global-search',
        },
      ],
    },
  },
});
./config/plugins.js
module.exports = ({ env }) => ({
  search: {
    enabled: env.bool('SEARCH_PLUGIN', false),
    config: {
      provider: 'algolia',
      providerOptions: {
        apiKey: env('ALGOLIA_PROVIDER_ADMIN_API_KEY'),
        applicationId: env('ALGOLIA_PROVIDER_APPLICATION_ID'),
      },
      prefix: 'custom-prefix_',
      excludedFields: ['createdAt', 'createdBy', 'updatedBy'],
      debug: true,
      contentTypes: [
        {
          name: 'api::podcast.podcast',
          index: 'podcast',
        },
        {
          name: 'api::episode.episode',
          index: 'episode',
          fields: ['id', 'title', 'subtitle', 'description', 'duration', 'type', 'keyWords', 'showNotes', 'podcast', 'hosts', 'quests'],
        },
        {
          name: 'api::category.category',
        },
      ],
    },
  },
});

Admin panel

Configuration by admin panel is coming soon! ✨

Future features

Multiple indexes
Before save/update/delete methods/lifecycles
Index conditions
Multiple providers support
Manage indexes from admin panel (e.g. View or Delete indexed objects)
Global search bar in admin panel (e.g. InstantSearch.js)
Edit this page on GitHub Updated at Fri, Feb 4, 2022