Connects Payload CMS to a Meilisearch instance and keeps indexes in step with collection data. Each configured collection maps to its own index, with selected fields synced on create, update and delete. It is registered in the plugins array with a host and an API key that can read, create and delete indexes and documents. The plugin is in alpha and breaking changes are expected.
Meilisearch integration plugin for Payload CMS
Installation
npm i @nouance/payload-meilisearch39
Stars
5
Forks
6
Open Issues
3 years ago
Last Updated
0
Weekly Downloads
v0.1.3
npm Version
28.9 KB
Unpacked Size
1
Dependencies
Trends appear after 7 days of data. Daily snapshots have not started yet.
Trends appear after 7 days of data. Daily snapshots have not started yet.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/606341828-root)<a href="https://payloaddirectory.dev/plugins/606341828-root"><img src="https://payloaddirectory.dev/badge/606341828-root.svg" alt="Payload Directory"></a>README
Expect breaking changes.
A plugin for Payload CMS to connect Meilisearch and Payload.
Roadmap to stable release:
yarn add @nouance/payload-meilisearch
# OR
npm i @nouance/payload-meilisearch
In the plugins array of your Payload config, call the plugin with options:
import { buildConfig } from "payload/config";
import meilisearchPlugin from "@nouance/payload-meilisearch";
const config = buildConfig({
plugins: [
meilisearchPlugin({
host: process.env.MEILISEARCH_HOST,
apiKey: process.env.MEILISEARCH_API_KEY,
}),
],
});
export default config;
host
Required. Your Meilisearch host URL.
apiKey
Required. Your Meilisearch API key. Must have permissions to read, create and delete indexes and documents.
sync
Required. An array of sync configs. This will automatically configure a sync between Payload collections and Meilisearch indexes. See sync for more details.
logs
Optional. When true, logs sync events to the console as they happen.
This option will sync collection's data and their fields to your Meilisearch instance. Each collection slug maps to a unique index in Meilisearch.
import { buildConfig } from "payload/config";
import meilisearchPlugin from "@nouance/payload-meilisearch";
const config = buildConfig({
plugins: [
meilisearchPlugin({
host: process.env.MEILISEARCH_HOST,
apiKey: process.env.MEILISEARCH_API_KEY,
sync: [
{
collection: "posts",
fields: [
{
name: "title",
},
{
name: "publishedDate",
alias: "publicationDate",
},
],
},
],
}),
],
});
export default config;
You can optionally set an alias that maps the field to a different name in Meilisearch's index in case you don't want to expose inner field names or want to simplify it.
In Meilisearch, every document must have an ID, by default we're setting this to be the document's ID, however you can change it to any other field by making your alias id. Note that this has to be unique and a valid format (eg. no spaces), so we recommend leaving it as default or applying a transformer function to make sure your data format is always correct.
On each field you can apply a transformer function that takes in the field value as it is from the doc object and then update operation's full doc object so that you can modify the values before the collection is indexed. This is useful for dealing with complex fields like RichText where you might want to serialise it into a string so it's easily searchable.
Example transformer to set the name of a category as the ID of the document:
{
name: "name",
alias: "id",
transformer: (doc) => {
const name: string = doc.name;
return name.replaceAll(" ", "-").toLocaleLowerCase();
},
},
For development purposes, there is a full working example of how this plugin might be used in the demo of this repo. This demo can be developed locally using any Meilisearch Cloud account, you just need a working API key. Then:
git clone [email protected]:NouanceLabs/payload-meilisearch.git \
cd payload-meilisearch && yarn \
cd demo && yarn \
cp .env.example .env \
vim .env \ # add your Meilisearch creds to this file
yarn dev
search
Generate fast-to-query search records from your Payload documents
10083.1k/wk45.4kv3
algolia search
Sync Payload collections to Algolia with draft-aware indexing, admin reindexing and headless React search hooks
540/wk15v3
payload plugin algolia
Sync Payload collections to an Algolia search index
480/wk17v3
payload algolia search
Sync Payload collections to Algolia with search and re-index endpoints and optional result enrichment
280/wk1v3
payload typesense
Typesense search for Payload with automatic document sync, search endpoints and a React search component
83235/wk32v3
payload related items
Related posts for Payload using BM25 and Jaccard similarity scoring, with no external AI service
410/wk3v3