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.
Property | Description | Type | Default value |
---|---|---|---|
provider | Name of the provider. | String (required) | |
providerOptions | Provider specific options, checkout the provider configuration for the required options. | Object | |
prefix | Set a prefix on all indexes. | String | strapi.config. environment + '_' |
excludedFields | Fields that are not indexed on all indexes. | Array<String> | ['created_by', 'updated_by'] |
debug | Enable or disable the debug logs. | Boolean | false |
contentTypes | List op indexes content types. | Array<Object> | |
contentTypes.name | UID of the content type. | String (required) | |
contentTypes.index | Name of the index. | String | contentTypes.name |
contentTypes.fields | Fields 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)