Skip to content

An API wrapper for Meilisearch written in CFML for the ColdBox platform

License

Notifications You must be signed in to change notification settings

coldbox-modules/cbmeilisearch

Repository files navigation

cbMeilisearch

An API wrapper for Meilisearch written in CFML for the ColdBox platform.

Getting Started

  1. Install via CommandBox - box install cbmeilisearch
  2. Start a Meilisearch instance
  3. Configure cbMeilisearch
    1. via environment variables
    2. via Coldbox.cfc's ModuleSettings
  4. Get the Client model: getInstance( "Client@cbmeilisearch" )
  5. Make API calls: msClient.createIndex( "movies" )

Starting Meilisearch

From the Meilisearch Quickstart guide:

# Fetch the latest version of Meilisearch image from DockerHub
docker pull getmeili/meilisearch:v0.30

# Launch Meilisearch in development mode with a master key
docker run --detach --rm \
    -p 7700:7700 \
    -e MEILI_MASTER_KEY='mySecretKey'\
    getmeili/meilisearch:v0.30 \
    meilisearch \
    --env="development"

Configuration via Environment Variables

CBMeilisearch will try to pull Meilisearch connection settings from the environment variables by default. You can take advantage of this by creating a .env file in the root of your ColdBox app and using commandbox-dotenv or a similar tool to load the .env file into your application on startup.

# .env
MEILISEARCH_HOST=https://127.0.0.1
MEILISEARCH_PORT=7700
MEILISEARCH_MASTER_KEY=mySecretKey

Configuration via Coldbox's ModuleSettings

Use the following example configuration to get started configuring cbMeilisearch.

For obvious reasons, the host/port must point to a running Meilisearch instance, and the MEILISEARCH_MASTER_KEY must be the configured master key you set when starting Meilisearch.

// config/Coldbox.cfc
component{
  function configure(){
    moduleSettings = {
      "cbmeilisearch" : {
        "MEILISEARCH_HOST" : "localhost",
        "MEILISEARCH_PORT" : 7700,
        "MEILISEARCH_MASTER_KEY" : "mySecretKey"
      }
    }
  }
}

Usage

This library follows the Meilisearch API reference as closely as possible.

🤖 Meilisearch Version Compatibility

This package guarantees compatibility with Meilisearch versions:

Versions v0.27.x and below are NOT supported due to the breaking changes introduced in v0.28.0.

TODO / Help Needed

Looking to contribute? I'd love to see help in these areas:

License

Apache License, Version 2.0.

The ColdBox Websites, logo and content have a separate license and they are a separate entity.

The Good News

For all have sinned, and come short of the glory of God (Romans 3:23)

But God commendeth his love toward us, in that, while we were yet sinners, Christ died for us. (Romans 5:8)

That if thou shalt confess with thy mouth the Lord Jesus, and shalt believe in thine heart that God hath raised him from the dead, thou shalt be saved. (Romans 10:9)

Repository

Copyright 2022 (and on) - Ortus Solutions