A Strapi plugin to integrate Orama Cloud's search and answers engine, providing seamless search capabilities within your Strapi application.
This Strapi plugin integrates Orama Cloud's search and answers engine into your Strapi application, providing seamless search capabilities.
npm install @oramacloud/plugin-strapi@latest
yarn add @oramacloud/plugin-strapi@latest
pnpm add @oramacloud/plugin-strapi@latest
npm install @oramacloud/plugin-strapi@^1.0.0
yarn add @oramacloud/plugin-strapi@^1.0.0
pnpm add @oramacloud/plugin-strapi@^1.0.0
Marketplace
section.Orama Cloud
and install the plugin.Configure the plugin in the config/plugins.js
file:
1// config/plugins.js
2
3module.exports = ({ env }) => ({
4 "orama-cloud": {
5 config: {
6 privateApiKey: env('ORAMA_PRIVATE_API_KEY'),
7 },
8 },
9});
Your ORAMA_PRIVATE_API_KEY
will be automatically generated when you create the index. You can also generate a new Private API Key in Developer tools page on Orama Cloud.
Configure and manage Collections
that map your Strapi app Content-Types with an Index
on Orama Cloud.
Check out the documentation: Connect to Strapi
config/plugins.js
configuration file.indexId
and visit your Strapi administration dashboard to configure your first collection.Collections map your Content-Types on Strapi with an index on Orama Cloud. To keep your index in sync with the data, you can configure the update settings for each collection.
Orama Cloud
from your Strapi admin menu to manage your collections.indexId
.When an index is not in sync with the latest changes in Strapi, the collection status is set to outdated
.
When the Scheduled job is executed, it checks the collection status, to avoid triggering an update if the data is
already in sync. You can always trigger a new deployment manually.
The scope of the transformation is to modify the document before it is sent to the Orama Cloud API. This can be useful to add, remove or modify fields in the document. A common use case is to change how a collection is handled (array of objects) to a flat structure this is not supported by Orama Cloud. Here is an example of how to transform a collection of objects to a flat structure:
Example document:
1{
2 "id": 1,
3 "owner": "John",
4 "cars": [
5 {
6 "brand": "Toyota",
7 "model": "Corolla"
8 },
9 {
10 "brand": "Ford",
11 "model": "Focus"
12 }
13 ]
14}
You can insert your transformer function directly inside the plugin configuration under config/plugins.js
file:
1module.exports = ({ env }) => ({
2 "orama-cloud": {
3 config: {
4 privateApiKey: env("ORAMA_PRIVATE_API_KEY"),
5 collectionSettings: {
6 your_collection_index_id: {
7 /* Mandatory */
8 schema: {
9 id: { type: "integer" },
10 owner: { type: "string" },
11 cars: {
12 brands: { type: "string" },
13 models: { type: "string" },
14 },
15 },
16 /* Mandatory */
17 transformer: entry => {
18 return {
19 ...entry,
20 owner: "Overriding owner",
21 cars: {
22 source: entry.cars,
23 ...entry.cars.reduce(car => {
24 acc.brands.push(car.brand);
25 acc.models.push(car.model);
26 return acc;
27 }, {
28 brands: [],
29 models: [],
30 }),
31 },
32 }
33 },
34 }
35 }
36 },
37 },
38})
In this way your cars will be transformed to:
1{
2 "id": 1,
3 "owner": "Overriding owner",
4 "cars": {
5 "brands": ["Toyota", "Ford"],
6 "models": ["Corolla", "Focus"]
7 }
8}
And make you car brands and models searchable.
:warning: Both schema and transformer are mandatory.
:warning: The transformer function must return an object with the same schema as the one declared.
:warning: All the properties not declared in it will be included in the document, but ignored while searching.
For more information about the plugin, please visit the Orama Cloud documentation.
npm install @oramacloud/plugin-strapi
Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.