SS 4.0 Site Search - How to enable?

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

SS version 4.0 (not 4.1 or 4.2)

Would someone please tell me how I enable site seach?

In 3.x it was a simple matter of adding FulltextSearchable::enable(); to mysite/_config.php but when I attempt this in 4.0 it throws an error on /dev/build.

Someone on here told me I need to add FulltextSearchable::enable(); to app/_config.php but version 4.0 doesn’t have an app subfolder. It has mysite in its place. From what I can see app came later, in 4.1+.

I tried adding the following to mysite/_config.php:

use SilverStripe\ORM\Search;
FulltextSearchable::enable();

But it threw an error on /dev/build (class ‘FulltextSearchable’ not found)

I then tried adding the following to /mysite/_config/theme.yml:

SilverStripe\ORM\Search\FulltextSearchable:
enabled: ‘true’

But that threw an error too.

Any advice please?

2 Likes

Managed to get it working :slight_smile:

I had to write the following:

Inside /mysite/_config.php, I wrote:

SilverStripe\ORM\Search\FulltextSearchable::enable();

And inside /mysite/_config/theme.yml, I appended:

SilverStripe\ORM\Search\FulltextSearchable:
enabled: ‘true’

And inside /mysite/code/Page.php, I appended:

use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\Connect\MySQLSchemaManager;

class MyDataObject extends DataObject
{
private static $create_table_options = [
MySQLSchemaManager::ID => ‘ENGINE=MyISAM’
];
}

Ran a /dev/build, and hey presto.

1 Like

You just have to enable FulltextSearchable in /mysite/_config.php or /app/_config.php. The other steps are not necessary:

use SilverStripe\ORM\Search\FulltextSearchable;
FulltextSearchable::enable();

See link: Basic Site Search in SilverStripe 4 - SilverStrip.es

Best Regards
Sebastian

I’ve just been struggling with this. The documentation is pretty sparse, but I found this little gem from Uncle Cheese which helped me a lot - SS ajax site search · GitHub
Also, this only works with MySQL 5.6+, so if your host has 5.5 you’ll need to look at converting the relevant tables to MyISAM, an area which I haven’t quite got to grips with yet