Freetext Search base package for SilverStripe searching

Installs: 1 518

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 10



Free Text Search

Build Scrutinizer Code Quality

Latest Stable Version Latest Unstable Version Total Downloads License Monthly Downloads Daily Downloads composer.lock

GitHub Code Size GitHub Repo Size GitHub Last Commit GitHub Activity GitHub Issues

This module allows configuration of freetext search indexes, and provides tools to create indexes and reindex them. By default only a sitetree index is configured, but one can add indexes for subclasses of SiteTree (e.g. a BlogPost) or a DataObject only index, e.g. flickr photos. The template for rendering the search results can also be overridden.

Note that one also has to install an implementation, currently only one for Manticore Search (formerly Sphinx) exists, package name is suilven/silverstripe-manticore-search



By default the core fields of SiteTree are indexed. You can override as follows to allow for third party modules or your own. Each index should map to a model class, and the field names match those in the database.

An example follows, code can be found at

Name: flickrfreetextsearch
After: freetextindexes


The above is compulsory. Additional indexes start here.

    - index:

The name of the index

        name: flickrphotos

The class of DataObject being indexed

        class: Suilven\Flickr\Model\Flickr\FlickrPhoto

These fields are indexed as free text.

          - Title
          - Description

It is not always desirable to show highlights from all of the fields, this is a filter list of fields to render highlights from in search results.

          - Title
          - Description

These fields are stored but not searchable. Their function is to provide fields to render in the search results, and avoid hydrating objects from the database. Note that Link is a hybrid field, the existence of a Link() method is checked for at indexing time and the field added if the method exists.

          - ThumbnailURL
          - Link

The following indexes correctly with Manticoresearch, but note that the ManticoreSearch PHP client does not currently allow for facetted searching. It is in pipeline though. Raw queries show facetted groups returned, but it makes sense to wait for this to be implemented in the PHP client instead.

Fields that can be used for facetted searching.

          - Aperture
          - ShutterSpeed
          - ISO
          - TakenAt

Have one fields are effectively another facet.

          - Suilven\Flickr\Model\Flickr\FlickrAuthor

This example shows how to index a has many field, tags, for facetting. Each entry has 3 fields:

  • name: the name of the relationship
  • relationship: The SilverStripe name of the relationship
  • field: The FlickrTags relationship is a data list of FlickrTag, the value stored is that of the RawValue field.
            name: tags
            relationship: FlickrTags
            field: RawValue


Any class referenced in indexes configuration needs the following extension, Suilven\FreeTextSearch\Extension\IndexingExtension, added. This performs one of two jobs:

  1. Index a DataObject immediately after it's been saved
  2. /or mark a DataObject as dirty and add a job to the queue to process the indexes affected.
Name: freetextindexes-flickr
After: freetextindexes-extensions

    - Suilven\FreeTextSearch\Extension\IndexingExtension

Indexing Mode

In the site configuration there is an additional tab called Free Text Search. It contains two fields:

  • FreeTextSearchIndexingModeInBulk - tick this to index in bulk via queue, untick to index immediately after writing to the database
  • BulkSize - the number of DataObjects to index at once


Via Composer

$ composer require suilven/freetextsearch



Note that these commands require an implementation of freetextsearch.

Creating an Index

Change the name of the index as appropriate. Note that when this command is run, the contents of the index will be dropped, and a reindex will be required.

vendor bin/sake dev/tasks/create-index index=sitetree

Reindexing an Index

Change the name of the index as appropriate. This will reindex in bulk.

vendor bin/sake dev/tasks/reindex index=sitetree

Adding a Search Page for an Index

In the CMS add a page of type Search Page. The following fields are editable:

  • IndexToSearch - the index to search, e.g. sitetree or flickrphotos
  • PageSize - the number of search results to return per page

The following are related to facets and not yet implemented:

  • ShowAllIfEmptyQuery - if this is ticked, search results will be shown for an empty query
  • ShowTagCloudFor - show tag cloud for a faceted field when there are no search results to be shown

Change log

Please see CHANGELOG for more information on what has changed recently.


$ vendor/bin/phpunit tests '' flush=1


Please see CONTRIBUTING and CODE_OF_CONDUCT for details.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.