PHPackages                             bimthebam/silverstripe-meilisearch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. bimthebam/silverstripe-meilisearch

ActiveSilverstripe-vendormodule[Search &amp; Filtering](/categories/search)

bimthebam/silverstripe-meilisearch
==================================

Easily integrate meilisearch into SilverStripe

1.0.1(2y ago)0763[1 PRs](https://github.com/bimthebam/silverstripe-meilisearch/pulls)BSD-3-ClausePHPPHP ^8.1

Since Aug 9Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/bimthebam/silverstripe-meilisearch)[ Packagist](https://packagist.org/packages/bimthebam/silverstripe-meilisearch)[ RSS](/packages/bimthebam-silverstripe-meilisearch/feed)WikiDiscussions main Synced yesterday

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

SilverStripe meilisearch module
===============================

[](#silverstripe-meilisearch-module)

Intro
-----

[](#intro)

This module adds support for connecting with meilisearch as (multi-lingual) full-text search engine.

**[meilisearch](https://www.meilisearch.com/)**

> An open-source, lightning-fast, and hyper-relevant search engine that fits effortlessly into your workflow.

Requirements
------------

[](#requirements)

- SilverStripe Framework 6.x
- PHP 8.3
- meilisearch &gt;= 1.3

### Optional

[](#optional)

- [silverstripe/cms](https://github.com/silverstripe/silverstripe-cms) — enables the built-in SiteTree index, SearchPage page type, and automatic page search integration
- [silverstripe-fluent](https://github.com/tractorcow-farm/silverstripe-fluent) — enables multi-locale indexing with separate indexes per language

Installation
------------

[](#installation)

`composer require bimthebam/silverstripe-meilisearch ^2.0`

Configuration
-------------

[](#configuration)

### Environment variables

[](#environment-variables)

VariableRequiredDescription`MEILISEARCH_HOST_AND_PORT`YesURL of your meilisearch instance, e.g. `http://your-meilisearch-host:7700``MEILISEARCH_MASTER_KEY`NoAuthentication key, if the meilisearch instance requires it`MEILISEARCH_INDEXES_PREFIX`NoPrefix for all index names, useful for shared meilisearch instancesUsage
-----

[](#usage)

### Initialization

[](#initialization)

Run the built-in task [RebuildAllIndexesTask](src/Dev/Task/RebuildAllIndexesTask.php), which will create all the needed indexes within your meilisearch instance and fills them up with contents.

Although not necessary, it is suggested to run the task from CLI.

e.g. `sake tasks:meilisearch-rebuild-all-indexes`

### Search

[](#search)

When `silverstripe/cms` is installed, this module comes with a pre-defined index for SiteTree. So searching in page contents should mostly work out of the box.

To start, simply add a new page of type [SearchPage](src/Model/CMS/SearchPage.php) to your site tree.

Without `silverstripe/cms`, the module provides the core indexing and search infrastructure for use with custom indexes.

Custom indexes
--------------

[](#custom-indexes)

### 1. Create a DataObject

[](#1-create-a-dataobject)

Define your DataObject and configure which fields meilisearch should use.

```
namespace App\Model;

use SilverStripe\ORM\DataObject;

class Product extends DataObject
{
    private static string $table_name = 'Product';

    private static array $db = [
        'Title' => 'Varchar(255)',
        'Description' => 'HTMLText',
        'Price' => 'Currency',
        'Category' => 'Varchar(100)',
        'IsActive' => 'Boolean',
    ];

    private static array $meilisearch_searchable_fields = [
        'Title',
        'Description',
    ];

    private static array $meilisearch_filterable_fields = [
        'Category',
        'IsActive',
    ];

    private static array $meilisearch_sortable_fields = [
        'Title',
        'Price',
    ];
}
```

If `meilisearch_searchable_fields` is not defined, the module falls back to `Title` and `Content` if present.

Field values are automatically processed based on their type:

Field typeProcessing`HTMLText`, `HTMLVarchar`HTML tags are stripped`Boolean`Cast to `bool``Date`, `Time`Converted to Unix timestampAll othersRaw value### 2. Create an Index class

[](#2-create-an-index-class)

```
namespace App\Search;

use App\Model\Product;
use BimTheBam\Meilisearch\Index;

class ProductIndex extends Index
{
    private static string $data_object_base_class = Product::class;

    private static array $excluded_classes = [];

    private static bool $check_can_view = false;
}
```

ConfigDescription`data_object_base_class`The DataObject class this index handles. All subclasses are included automatically.`excluded_classes`Array of DataObject subclasses to exclude from the index.`check_can_view`If `true`, search results are filtered by `canView()` permissions.### 3. Apply the Searchable extension

[](#3-apply-the-searchable-extension)

For **non-versioned** DataObjects, apply the `Searchable` extension. This automatically updates the index on write and delete.

```
# app/_config/meilisearch.yml
App\Model\Product:
  extensions:
    - BimTheBam\Meilisearch\Model\Extension\Searchable
```

For **versioned** DataObjects, use `SearchableVersioned` instead. This updates the index on publish/unpublish rather than on write.

```
App\Model\Product:
  extensions:
    - BimTheBam\Meilisearch\Model\Extension\SearchableVersioned
```

### 4. Build and populate

[](#4-build-and-populate)

Run `dev/build` to apply the extension, then rebuild the index:

```
sake dev/build
sake tasks:meilisearch-rebuild-all-indexes
```

After the initial rebuild, the index is kept in sync automatically via the extension hooks.

### 5. Searching programmatically

[](#5-searching-programmatically)

```
use App\Search\ProductIndex;

$index = ProductIndex::create();
$results = $index->search('search term');

// Access results
foreach ($results->getList() as $result) {
    $product = $result->getRecord(); // Lazy-loads the DataObject
    echo $product->Title;
}

// Paginated results
$paginated = $results->getList(paginated: true, perPage: 10);
```

The `search()` method accepts additional parameters:

```
$results = $index->search(
    q: 'search term',
    filter: ['Category = "Electronics"', 'IsActive = true'],
    limit: 50,
    sort: ['Price:asc'],
);
```

Filter and sort syntax follows the [meilisearch documentation](https://www.meilisearch.com/docs/learn/filtering_and_sorting/filter_search_results).

### Using the SearchForm

[](#using-the-searchform)

If you have multiple indexes, the built-in [SearchForm](src/Form/SearchForm.php) automatically offers a checkbox to let users choose which indexes to search in. Custom indexes are included alongside the SiteTree index (if available) without any additional configuration.

ToDo
----

[](#todo)

- Add support for authentication keys
- Complete documentation for custom indexes

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance56

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1060d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9837249476c237bd1885f45ef4da46dbccc2556c4940323d654c3726a72c4dbd?d=identicon)[bimthebam](/maintainers/bimthebam)

---

Top Contributors

[![bimthebam](https://avatars.githubusercontent.com/u/3392650?v=4)](https://github.com/bimthebam "bimthebam (9 commits)")[![rasstislav](https://avatars.githubusercontent.com/u/9253113?v=4)](https://github.com/rasstislav "rasstislav (3 commits)")

---

Tags

searchmeilisearchsilverstripefulltext search

### Embed Badge

![Health badge](/badges/bimthebam-silverstripe-meilisearch/health.svg)

```
[![Health](https://phpackages.com/badges/bimthebam-silverstripe-meilisearch/health.svg)](https://phpackages.com/packages/bimthebam-silverstripe-meilisearch)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[silverstripe/framework

The SilverStripe framework

7313.7M2.8k](/packages/silverstripe-framework)[statamic-rad-pack/meilisearch

meilisearch search driver for Statamic

1675.5k](/packages/statamic-rad-pack-meilisearch)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
