@nodedk/meilisearch
meilisearch#
Create a configured Meilisearch SDK client.
Requirements#
A running Meilisearch instance and its API key when authentication is enabled.
Install#
npm i @nodedk/meilisearch
Usage#
var { client } = require('@nodedk/meilisearch')
async function main() {
var search = client({
host: 'http://127.0.0.1:7700',
apiKey: process.env.MEILI_API_KEY
})
var result = await search.index('products').search('coffee', {
limit: 10
})
console.log(result.hits)
}
main().catch(console.error)
API#
client(options = {})#
Returns a native Meilisearch client synchronously. options overrides the wrapper defaults and is passed to the SDK:
host: server URL; defaults tohttp://127.0.0.1:7700.apiKey: API key. Supply your instance's key; the wrapper otherwise uses a built-in development key. Passundefinedexplicitly for a server without authentication.- Other options use the Meilisearch JavaScript SDK configuration.
Use client.index(uid) for the native index API, including search(query, options) and addDocuments(documents, options). The wrapper adds no index methods. Use @nodedk/search for JSON filters and sorting.
Development#
Start a local server with Docker. Set MEILI_MASTER_KEY first; use that same key in the client.
docker run --rm --name meilisearch -p 7700:7700 \
-e MEILI_MASTER_KEY="$MEILI_MASTER_KEY" \
-v "$PWD/meili_data:/meili_data" \
getmeili/meilisearch
Stop it from another terminal:
docker stop meilisearch
Created by Vidar Eldøy