Files
medusa-store/packages/medusa-plugin-meilisearch/README.md
Tsvetan Nikolov 3e2fe07d0a docs: fix transformer option in meilisearch documentation (#4250)
* Fixed documentation about meilisearch transformer function

* updated medusa-plugin-meilisearch readme

---------

Co-authored-by: Tsvetan Nikolov <tsvetan.nikolov@coliquio.de>
Co-authored-by: Shahed Nasser <shahednasser@gmail.com>
2023-06-06 11:08:56 +03:00

2.5 KiB

MeiliSearch

Provide powerful indexing and searching features in your commerce application with MeiliSearch.

MeiliSearch Plugin Documentation | Medusa Website | Medusa Repository

Features

  • Flexible configurations for specifying searchable and retrievable attributes.
  • Ready-integration with Medusa's Next.js starter storefront.
  • Utilize MeiliSearch's powerful search functionalities including typo-tolerance, synonyms, filtering, and more.

Prerequisites


How to Install

1. Run the following command in the directory of the Medusa backend:

npm install medusa-plugin-meilisearch

2. Set the following environment variables in .env:

MEILISEARCH_HOST=<YOUR_MEILISEARCH_HOST>
MEILISEARCH_API_KEY=<YOUR_MASTER_KEY>

3. In medusa-config.js add the following at the end of the plugins array:

const plugins = [
  // ...
  {
    resolve: `medusa-plugin-meilisearch`,
    options: {
      config: {
        host: process.env.MEILISEARCH_HOST,
        apiKey: process.env.MEILISEARCH_API_KEY,
      },
      settings: {
        products: {
          indexSettings: {
            searchableAttributes: [
              "title", 
              "description",
              "variant_sku",
            ],
            displayedAttributes: [
              "title", 
              "description", 
              "variant_sku", 
              "thumbnail", 
              "handle",
            ],
          },
          primaryKey: "id",
          transformer: (product) => ({
            id: product.id, 
            // other attributes...
          }),
        },
      },
    },
  },
]

Test the Plugin

1. Run the following command in the directory of the Medusa backend to run the backend:

npm run start

2. Try searching products either using your storefront or using the Store APIs.


Additional Resources