Skip to main content

Meilisearch Search

Overview​

ID86 uses server-side Meilisearch for fuzzy, typo-tolerant search. Documentation posts are indexed in a Meilisearch instance running on the production host (GC-US-M10). The browser queries a WordPress REST endpoint (/wp-json/id86/v1/search) which proxies to Meilisearch on 127.0.0.1:7700.

The whole integration lives in the standalone meilisearch-id86 plugin (wp-content/plugins/meilisearch-id86), not in the child theme. The plugin owns the REST proxy, indexing hooks, filter builder/parser, search UI (hero + command palette), admin settings, and its own CSS/JS assets.

Search-First Priority​

The homepage is intentionally search-first:

  • Perfmatters optimizations (delay JS, defer JS, remove unused CSS, lazy load) are disabled on the front page so the search bar is interactive immediately.
  • GeneratePress native search is replaced with the Meilisearch command palette.
  • The homepage header omits the search trigger because the hero search is the primary entry point.

Search Surfaces​

SurfaceSelectorVisible on
Homepage Hero#fusejs-input / #fusejs-resultsFront page only
Command Palette#id86-fuse-palette-input / #id86-fuse-palette-resultsAll pages; header trigger hidden on the desktop front page

On the desktop front page the header search trigger is hidden by CSS (body.home #site-navigation .id86-search-trigger) so the hero search is the sole entry point. On tablet/mobile the header search trigger appears in the top bar on every page, including the front page.

Plugin Layout​

Source (canonical dev checkout): /home/rezriz/github/Wordpress/wp-dev/plugins/develop-internally/meilisearch-id86

FileRole
meilisearch-id86.phpPlugin bootstrap, version 1.0.2, activation hook (seeds id86_meilisearch_key from MEILI_MASTER_KEY)
inc/class-meilisearch-client.phpMeilisearch helpers, filter builder/parser, indexing hooks, REST route
inc/class-search-ui.phpAsset enqueue, hero shortcode, palette markup, header trigger registration
inc/class-admin.phpSettings page (Settings → Meilisearch ID86)
assets/css/search.cssPalette/hero styling (self-contained)
assets/js/id86-meilisearch-global.jsFrontend search client for both surfaces

Index Building​

The plugin indexes posts in Meilisearch via Meilisearch_Client::index_post(), hooked on save_post (priority 20). It also removes documents on before_delete_post and wp_trash_post. Only published posts carrying the _id86_content_type post meta are indexed; unpublished or untyped posts are deleted from the index. Each document contains:

  • id — Post ID (primary key)
  • title — Post title
  • excerpt — Post excerpt or trimmed content
  • url — Permalink
  • category — Comma-joined category names
  • content_type — Documentation content type
  • tags — Tag names array
  • updated_at — Modified date (Y-m-d)

Meilisearch index: id86-docs. Searchable attributes: title, excerpt, category, tags. Filterable: category, content_type, tags. Sortable: updated_at.

Filtering​

The search supports conditional filters in both the input and the REST API. Multiple filters combine with AND; multiple tags use OR.

Filter syntax (search input)​

  • topic:code git — filter to the "Code" topic, search "git".
  • category:code, cat:code — aliases for topic:.
  • tag:docker, tags:docker — filter by tag.
  • type:reference, content_type:reference — filter by content type.
  • :docker — shorthand filter (matches tag, topic, or content type). This is what the search placeholder advertises.
  • Combine: topic:code :git (AND).

Filter tokens are stripped from the free-text query and shown as active-filter chips above the results.

REST API​

GET /wp-json/id86/v1/search?q=<query>&category=<cat>&tag=<tag>&content_type=<type>&auto_filter=<value>
  • q — search text (optional when filters present).
  • category — single category filter.
  • tag — comma-separated tag list (OR).
  • content_type — single content type filter.
  • auto_filter — comma-separated shorthand values.
  • Response: { "hits": [...], "total": N, "filters": { ... } }.

The REST proxy forwards a POST to Meilisearch (/indexes/<index>/search) with a JSON body (q, limit, filter).

Frontend​

The file assets/js/id86-meilisearch-global.js (plugin) handles both search surfaces:

  • Debounced (200 ms) fetch to /wp-json/id86/v1/search?q=....
  • Results show: highlighted title → metadata chips (first category + up to 2 tags) → 120-char excerpt.
  • Keyboard navigation: arrows select results, Enter opens, Escape closes.
  • The hero input is cloned on initialization to avoid plugin DOM conflicts.
  • Active filter tokens render as chips above the results.

Header Trigger​

The plugin restores the header search icon that was lost when the integration moved out of the child theme. Search_UI::register_header_trigger() runs on wp (priority 20), removes GeneratePress' own search modal trigger (generate_do_search_modal_trigger / generate_do_search_modal), and registers render_header_trigger on generate_menu_bar_items. The trigger renders [data-id86-fuse-open], so the palette opens on every page, including single posts.

Dependencies​

ResourceSource
Plugin CSSmeilisearch-id86/assets/css/search.css
Plugin JSmeilisearch-id86/assets/js/id86-meilisearch-global.js
Meilisearchhttp://127.0.0.1:7700 (production host)

No Fuse.js CDN is used.

Admin Settings​

Configured under Settings → Meilisearch ID86 (or wp_options):

  • id86_meilisearch_url — Meilisearch base URL (default http://127.0.0.1:7700).
  • id86_meilisearch_index — index name (default id86-docs).
  • id86_meilisearch_key — API key (falls back to MEILI_MASTER_KEY env var).

Filters for reuse on other sites: id86_meilisearch_url, id86_meilisearch_index, id86_content_types.

Performance​

  • Front page: Perfmatters optimizations are disabled entirely so search is interactive immediately.
  • REST endpoint proxies to localhost Meilisearch (sub-50 ms).
  • Master key is stored in wp_options (id86_meilisearch_key), never in Git.

Maintenance​

  • Verify both search surfaces after changing the index format or the renderer.
  • Re-index all posts via WP-CLI: wp eval-file reindex.php (or trigger save_post).
  • Keep CSS class names (.fusejs-*) so no CSS changes are needed.
  • Plugin version: 1.0.2 (see plugin CHANGELOG.md).