MeiliSearch | Documentation | Slack | Website | FAQ
A plugin to index your Gatsby content to MeiliSearch based on graphQL queries
- 📖 Documentation
- 🔧 Installation
- 🏃♀️ Run MeiliSearch
- 🎬 Usage
- 🤖 Compatibility with MeiliSearch and Gatsby
- ⚙️ Development Workflow and Contributing
To understand MeiliSearch and how it works, see the MeiliSearch's documentation.
To understand Gatsby and how it works, see Gatsby's documentation.
Inside your Gatsby app, add the package:
With npm
:
npm install gatsby-plugin-meilisearch
With yarn
:
yarn add gatsby-plugin-meilisearch
There are many easy ways to download and run a MeiliSearch instance.
For example, if you use Docker:
docker pull getmeili/meilisearch:latest # Fetch the latest version of MeiliSearch image from Docker Hub
docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey
gatsby-config.js
{
resolve: 'gatsby-plugin-meilisearch',
options: {
// Host on which your MeiliSearch instance is running
host: 'http://localhost:7700',
indexes: [
{
// Index in which the content will be added
indexUid: `my_blog`,
// Function that transforms the fetched data before sending it to MeiliSearch
transformer: data => data.allMdx.edges.map(({ node }) => node),
// graphQL query that fetches the data to index in MeiliSearch
query: `
query MyQuery {
allMdx {
edges {
node {
id
slug
frontmatter {
title
cover
}
tableOfContents
}
}
}
}
`,
}
],
},
}
The plugin accepts the following options for further customization :
{
resolve: 'gatsby-plugin-meilisearch',
options: {
apiKey: "masterKey", // API key if the MeiliSearch instance is password protected
skipIndexing: true, // Run script without indexing to MeiliSearch. Default to false
batchSize: 1000, // The number of documents that should be included in each batch. Default to 1000
settings: {
searchableAttributes: ['title'], // MeiliSearch's settings. See https://docs.meilisearch.com/reference/features/settings.html
},
},
}
Supported Gatsby versions:
- Gastby v4.3.x
(This plugin may work with the older Gatsby versions, but these are not tested nor officially supported at this time.)
Supported MeiliSearch versions:
This package only guarantees the compatibility with the version v0.24.0 of MeiliSearch.
Node / NPM versions:
- NodeJS >= 14.15.X && <= 16.X
- NPM >= 6.x
We recommend always using the latest version of Gatsby to start your new projects.
Any new contribution is more than welcome in this project!
If you want to know more about the development workflow or want to contribute, please visit our contributing guidelines for detailed instructions!