Webhook icon
Schedule icon
Request icon
Script icon
DocumentAdd icon
Search icon
FacetSearch icon
If icon
Log icon

Meilisearch Synonym Dictionary and Search Relevance Regression Gate

Stage Meilisearch synonym updates, run canary recall and category bleed queries against an isolated index, and gate production promotion with Kestra.

Categories
Data

Search synonym dictionaries are critical for e-commerce conversion, enabling shoppers to find products across regional dialects and colloquialisms (such as mapping trainers to sneakers or running shoes). However, introducing unverified or overly broad synonym mappings directly into production search settings can severely degrade relevance, cause category bleed, or dilute ranking for high-value keywords.

This blueprint implements an automated staging and relevance regression gate for Meilisearch. It spins up an isolated canary index ({{ inputs.production_index }}_synonym_canary), ingests representative multi-category catalog documents via io.kestra.plugin.meilisearch.DocumentAdd, and applies the proposed synonym dictionary via Meilisearch's settings API. It then executes automated validation queries using io.kestra.plugin.meilisearch.Search and io.kestra.plugin.meilisearch.FacetSearch to verify both positive recall expansion and negative category isolation. Only when all canary checks pass does Kestra promote the synonyms to the live production index. If regressions are detected, the canary index is purged and production remains completely protected.

How it works

  1. stage_canary_index (io.kestra.plugin.core.http.Request) creates an isolated staging index with the primary key id.
  2. configure_canary_attributes (io.kestra.plugin.core.http.Request) sets filterable attributes (category, brand, in_stock) required for faceted query verification.
  3. prepare_sample_corpus (io.kestra.plugin.scripts.python.Script) writes a representative multi-category product dataset to corpus.json in Kestra internal storage.
  4. index_canary_documents (io.kestra.plugin.meilisearch.DocumentAdd) bulk-indexes the documents into the canary index, setting waitForIndexing: true to ensure the asynchronous indexing task completes before search queries run.
  5. apply_staged_synonyms (io.kestra.plugin.core.http.Request) submits the proposed synonym dictionary (trainers -> running shoes, sneakers) to the canary index.
  6. canary_synonym_recall_search (io.kestra.plugin.meilisearch.Search) searches for the synonym query trainers, verifying that documents containing running shoes are successfully retrieved.
  7. canary_control_bleed_search (io.kestra.plugin.meilisearch.Search) executes a control query for an unrelated keyword (mechanical keyboard) to verify that the synonym update caused no negative ranking bleed or cross-category contamination.
  8. canary_facet_distribution_search (io.kestra.plugin.meilisearch.FacetSearch) checks that facet counts for Footwear accurately reflect the expanded result set.
  9. evaluate_relevance_gate (io.kestra.plugin.core.flow.If) requires all three canary checks to pass: synonym recall hits, control query hits, and facet distribution hits.
    • Then (Validation Passed): If auto_promote is true, promote_synonyms_to_production applies the verified dictionary to inputs.production_index, followed by cleanup_canary_index to reclaim cluster memory.
    • Else (Validation Failed): Purges the canary index and emits a structured error log detailing the relevance breach, leaving the live index untouched.
  10. The flow-level errors block guarantees automatic cleanup of the canary index if any task encounters an unhandled exception.

What you get

  • Automated regression testing for search synonym changes before customer-facing traffic is affected.
  • Dual validation covering both positive recall expansion and negative control isolation.
  • Facet distribution verification to ensure merchandising filters remain consistent.
  • Safe automated promotion to the live production index upon passing all canary gates.
  • Complete cleanup of temporary canary indices on both success and failure paths.

Who it's for

  • Search Platform Engineers managing Meilisearch or Algolia clusters.
  • E-commerce Merchandisers tuning search dictionaries, synonyms, and product discoverability.
  • Data Platform Teams building GitOps pipelines for search engine configuration management.

Why orchestrate this with Kestra

Ad-hoc curl scripts or manual updates to search engine settings offer no safety net: a typo in a synonym JSON payload can instantly degrade search relevance for thousands of active shoppers. Kestra provides declarative workflow orchestration that stages changes, runs automated canary suites, conditionally promotes approved settings, and rolls back cleanly on failure. Built-in secret masking protects your Meilisearch master API key, while webhook triggers allow instant integration with CMS or merchandising dashboards.

Prerequisites

  • A running Meilisearch instance (v1.6+) accessible over HTTP/HTTPS.
  • An API key with administrative permissions to modify index settings and documents.

Secrets

  • MEILISEARCH_API_KEY: Administrative API key or master key for Meilisearch authentication.
  • MEILISEARCH_SYNONYM_WEBHOOK_KEY: Secret authentication key for the event-driven webhook trigger.

Quick start

  1. Start a local Meilisearch container with Docker:

    docker run -d -p 7700:7700 \
      -v /tmp/meili_data:/meili_data \
      getmeili/meilisearch:v1.12 \
      --master-key="testMasterKey12345"
    
  2. Create the production index with initial schema:

    curl -X POST "http://localhost:7700/indexes" \
      -H "Authorization: Bearer testMasterKey12345" \
      -H "Content-Type: application/json" \
      -d '{"uid": "products", "primaryKey": "id"}'
    
  3. Configure the required secrets in your Kestra namespace:

    • MEILISEARCH_API_KEY: testMasterKey12345
    • MEILISEARCH_SYNONYM_WEBHOOK_KEY: secret-webhook-key-67890
  4. Execute the flow in Kestra and inspect the logs to verify the canary tests and synonym promotion.

How to extend

  • Connect prepare_sample_corpus to an upstream database extract or S3 catalog dump to test synonyms against production product datasets.
  • Add Slack or Microsoft Teams notification tasks inside the then and else blocks to notify the merchandising team of promotion outcomes.
  • Extend the dictionary payload in apply_staged_synonyms to accept dynamic JSON inputs passed through the webhook body.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.