NouanceLabs

payload meilisearch

by NouanceLabs
Search
v1
^1.1.8
MIT

Overview

Summary generated from the README

Connects Payload CMS to a Meilisearch instance and keeps indexes in step with selected collections. Configured through the plugins array with a host, API key and per-collection sync settings. Fields can be aliased or transformed before indexing. The plugin is in alpha and targets Payload 1.x.

Features

  • Syncs collection documents to Meilisearch on create, update and delete
  • Maps each collection slug to its own index
  • Field aliases to rename or hide internal field names
  • Transformer functions to modify values, such as serialising rich text, before indexing
  • Supports code, date, email, JSON, number, point, radio, select, text and textarea fields
  • Optional console logging of sync events

Use cases

  • Add fast full-text search to a Payload site backed by a Meilisearch instance
  • Expose simplified field names in search indexes by aliasing internal fields

From the author

Meilisearch integration plugin for Payload CMS

Installation

npm i @nouance/payload-meilisearch

39

Stars

4

Forks

6

Open Issues

3 years ago

Last Updated

23

Weekly Downloads

v0.1.3

npm Version

28.9 KB

Unpacked Size

1

Dependencies

GitHub stars

390 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 202639
Dec 4, 202639
Dec 3, 202639
Dec 2, 202639
Dec 1, 202639
Nov 30, 202639
Nov 29, 202639
Nov 28, 202639
Nov 27, 202639
Nov 26, 202639
Nov 25, 202639
Nov 24, 202639
Nov 23, 202639
Nov 22, 202639
Nov 21, 202639
Nov 20, 202639
Nov 19, 202639
Nov 18, 202639
Nov 17, 202639
Nov 16, 202639
Nov 15, 202639
Nov 14, 202639
Nov 13, 202639
Nov 12, 202639
Nov 11, 202639
Nov 10, 202639
Nov 9, 202639
Nov 8, 202639
Nov 7, 202639
Nov 6, 202639
Nov 5, 202639
Nov 4, 202639
Nov 3, 202639
Nov 2, 202639
Nov 1, 202639
Oct 31, 202639
Oct 30, 202639
Oct 29, 202639
Oct 28, 202639
Oct 27, 202639
Oct 26, 202639
Oct 25, 202639
Oct 24, 202639
Oct 23, 202639
Oct 22, 202639
Oct 21, 202639
Oct 20, 202639
Oct 19, 202639
Oct 18, 202639
Oct 17, 202639
Oct 16, 202639
Oct 15, 202639
Oct 14, 202639
Oct 13, 202639
Oct 12, 202639
Oct 11, 202639
Oct 10, 202639
Oct 9, 202639
Oct 8, 202639
Oct 7, 202639
Oct 6, 202639
Oct 5, 202639
Oct 4, 202639
Oct 3, 202639
Oct 2, 202639
Oct 1, 202639
Sep 30, 202639
Sep 29, 202639
Sep 28, 202639
Sep 27, 202639
Sep 26, 202639
Sep 25, 202639
Sep 24, 202639
Sep 23, 202639
Sep 22, 202639
Sep 21, 202639
Sep 20, 202639
Sep 19, 202639
Sep 18, 202639
Sep 17, 202639
Sep 16, 202639
Sep 15, 202639
Sep 14, 202639
Sep 13, 202639
Sep 12, 202639
Sep 11, 202639
Sep 10, 202639
Sep 9, 202639
Sep 8, 202639
Sep 7, 202639
Sep 6, 202639
npm weekly downloads

22+5 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202622
Dec 4, 202613
Dec 3, 202613
Dec 2, 20266
Dec 1, 20269
Nov 30, 202611
Nov 29, 202610
Nov 28, 202610
Nov 27, 202610
Nov 26, 202611
Nov 25, 202611
Nov 24, 202611
Nov 23, 202611
Nov 22, 202612
Nov 21, 202634
Nov 20, 202636
Nov 19, 202635
Nov 18, 202640
Nov 17, 202638
Nov 16, 202639
Nov 15, 202636
Nov 14, 202619
Nov 13, 202631
Nov 12, 202636
Nov 11, 202631
Nov 10, 202632
Nov 9, 202629
Nov 8, 202634
Nov 7, 202630
Nov 6, 202615
Nov 5, 202611
Nov 4, 202614
Nov 3, 202612
Nov 2, 202613
Nov 1, 20267
Oct 31, 20266
Oct 30, 20266
Oct 29, 20264
Oct 28, 20261
Oct 27, 20262
Oct 26, 20263
Oct 25, 20263
Oct 24, 20263
Oct 23, 20263
Oct 22, 20264
Oct 21, 20268
Oct 20, 20267
Oct 19, 20265
Oct 18, 20266
Oct 17, 20267
Oct 16, 20267
Oct 15, 20266
Oct 14, 20267
Oct 13, 20267
Oct 12, 20267
Oct 11, 20267
Oct 10, 20266
Oct 9, 20269
Oct 8, 202613
Oct 7, 20268
Oct 6, 202611
Oct 5, 202611
Oct 4, 202613
Oct 3, 202613
Oct 2, 202611
Oct 1, 20267
Sep 30, 202610
Sep 29, 20267
Sep 28, 202610
Sep 27, 20267
Sep 26, 202614
Sep 25, 202616
Sep 24, 202619
Sep 23, 202616
Sep 22, 202621
Sep 21, 202626
Sep 20, 202626
Sep 19, 202619
Sep 18, 202616
Sep 17, 202615
Sep 16, 202617
Sep 15, 202615
Sep 14, 20267
Sep 13, 20267
Sep 12, 20269
Sep 11, 202611
Sep 10, 202614
Sep 9, 202615
Sep 8, 202614
Sep 7, 202617
Sep 6, 202617

Each point is npm's rolling 7-day download count.

Health Score

39/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/606341828-root.svg)](https://payloaddirectory.dev/plugins/606341828-root)
HTML
<a href="https://payloaddirectory.dev/plugins/606341828-root"><img src="https://payloaddirectory.dev/badge/606341828-root.svg" alt="Payload Directory"></a>
Updated May 29, 2023Created Feb 25, 2023Published Feb 26, 2023

README

Payload Meilisearch Plugin (ALPHA)

Expect breaking changes.

A plugin for Payload CMS to connect Meilisearch and Payload.

Roadmap to stable release:

  • Sync collections on create and update
  • Delete collections
  • Support all field types of Payload (in progress)
  • Support for Payload's draft system (planned)
  • Support for nested fields (planned)
  • Support Meilisearch index options for filtering and sorting (planned)

Installation

  yarn add @nouance/payload-meilisearch
  # OR
  npm i @nouance/payload-meilisearch

Basic Usage

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;

Options

  • 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.

Sync

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;

Alias

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.

Alias the ID

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.

Transformers

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();
  },
},

Curently supported field types

  • Code
  • Date
  • Email
  • JSON
  • Number
  • Point
  • Radio group
  • Select
  • Text
  • Textarea

Development

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

Similar plugins