Site search in SS4

Silverstripe Version: 4.7.1


I have FulltextSearchable enabled in my config and a working site search. However, how do I exclude files in my assets folder (that are meant to only be viewable by logged in members) from appearing in search results?

In the FulltextSearchable API it warns:

  • CAUTION: Will make all files in your /assets folder searchable by file name
  • unless “File” is excluded from FulltextSearchable::enable().

How do I do this for member-only files?

I know it’s been a while since you posted but did you fix the issue in the end?

In your _config.php, you can just pass an array without ‘File’ to exclude assets - something like this:


That should remove all the files from the results as it’s only enabled for SiteTree class therefore removing the files altogether…

Edit: sorry that’s exactly what you’re saying. Ignore.

FYI, looking in the SearchForm class getResults function the results are filtered by the records canView() function so I’d start there by writing some member only logic in the canView().

1 Like