FulltextSearchable#

Fulltext search allows advanced search criteria for searching words within a text based data column. While basic Fulltext search can be achieved using the built-in MySQLDatabase class a more powerful wrapper for Fulltext search is provided through a module.

The FulltextSearchable extension will add the correct Fulltext indexes to the data model.

CAUTION

The SearchForm and FulltextSearchable API's are currently hard coded to be specific to Page and File records and cannot easily be adapted to include custom DataObject instances. To include your custom objects in the default site search, have a look at those extensions and modify as required.

Fulltext filter#

Silverstripe CMS provides a FulltextFilter which you can use to perform custom fulltext searches on DataLists.

Example DataObject:

php
namespace App\Model;

use SilverStripe\ORM\DataObject;

class SearchableDataObject extends DataObject
{
    private static $db = [
        'Title' => 'Varchar(255)',
        'Content' => 'HTMLText',
    ];

    private static $indexes = [
        'SearchFields' => [
            'type' => 'fulltext',
            'columns' => ['Title', 'Content'],
        ],
    ];
}

Performing the search:

php
use App\Model\SearchableDataObject;

SearchableDataObject::get()->filter('SearchFields:Fulltext', 'search term');

If your search index is a single field size, then you may also specify the search filter by the name of the field instead of the index.

API documentation#