Index Strapi articles to Algolia indexes
A strapi plugin to sync your strapi content with Algolia.
yarn add strapi-plugin-strapi-algolia@latest
npm install --save strapi-plugin-strapi-algolia@latest
yarn add strapi-plugin-strapi-algolia@1
npm install --save strapi-plugin-strapi-algolia@1
ALGOLIA_ADMIN_KEY=your_algolia_app_id
ALGOLIA_APP_ID=your_algolia_api_key
Add the following code to ./config/plugins.js
1'use strict';
2
3module.exports = ({ env }) => ({
4 // ...
5 'strapi-algolia': {
6 enabled: true,
7 config: {
8 apiKey: env('ALGOLIA_ADMIN_KEY'),
9 applicationId: env('ALGOLIA_APP_ID'),
10 contentTypes: [
11 { name: 'api::article.article' },
12 // ...
13 ],
14 },
15 },
16});
Add the following code to ./config/plugins.ts
1export default ({ env }) => ({
2 // ...
3 'strapi-algolia': {
4 enabled: true,
5 config: {
6 apiKey: env('ALGOLIA_ADMIN_KEY'),
7 applicationId: env('ALGOLIA_APP_ID'),
8 contentTypes: [
9 { name: 'api::article.article' },
10 // ...
11 ],
12 },
13 },
14});
Property | Description | Type | Default value |
---|---|---|---|
applicationId | Algolia application ID | string (required) | |
apiKey | Algolia API Key | string (required) | |
indexPrefix | Prefix for the Algolia index | string | `${strapi.config.environment}_` |
contentTypes | Array of content types needed to be indexed | Array\<object> (required) | |
contentTypes.name | Name of the content type | string (required) | |
contentTypes.index | Algolia index for the current content type | string | |
contentTypes.idPrefix | Prefix for the item id | string | |
contentTypes.populate | Which fields needed to be indexed on Algolia, by default all the properties are indexed | object | '*' = All fields |
contentTypes.hideFields | Which fields needed to be hidden on Algolia, by default all the properties are indexed | Array\<string> | [] |
contentTypes.transformToBooleanFields | Which fields needed to be transform from null to boolean on Algolia | Array\<string> | [] |
For each content type configured in the plugin, a new button will be added to the content type list. This button will allow you to index all the content of the content type.
Call the following endpoint /strapi-algolia/index-all-articles
with POST method.
The body must be like this:
1{
2 "name": "api::article.article"
3}
You must be admin and add an authorization bearer token in the header.
1Authorization: Bearer YOUR_TOKEN
curl --request POST \
--url https://YOUR_STRAPI_INSTANCE/strapi-algolia/index-all-articles \
--header 'Authorization: Bearer YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"name": "api::article.article"
}'
npm install strapi-plugin-strapi-algolia
Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.