Silverstripe Version:
4.2.1
Question:
Hi,
I’ve been playing around with FulltextSearchable.
I’ve enabled it in _config.php with
FulltextSearchable::enable();
And I’ve managed to get the default implementation working by including $SearchForm in a template, as outlined in this tutorial:
https://docs.silverstripe.org/en/3/tutorials/site_search/
Other docs I’ve read seem to indicate that I should be able to use a “Fulltext” filter in database queries now, so I tried code like the following:
$keywords = $this->request->param('Keywords');
$results = SiteTree::get();
$results = $results->filter([
'Content:Fulltext' => $keywords
]);
return ['SearchResults' => $results ];
The code above recognises Fulltext as a filter (if I use a non-existant filter e.g fulltext instead of Fulltext I get an error about non-existing filter)
However, when I use ‘Content:Fulltext’ => $keywords, I get a database error:
# [Emergency] Uncaught SilverStripe\ORM\Connect\DatabaseException: Couldn't run query: SELECT DISTINCT "SiteTree_Live"."ClassName", "SiteTree_Live"."LastEdited", "SiteTree_Live"."Created", "SiteTree_Live"."CanViewType", "SiteTree_Live"."CanEditType", "SiteTree_Live"."Version", "SiteTree_Live"."URLSegment", "SiteTree_Live"."Title", "SiteTree_Live"."MenuTitle", "SiteTree_Live"."Content", "SiteTree_Live"."MetaDescription", "SiteTree_Live"."ExtraMeta", "SiteTree_Live"."ShowInMenus", "SiteTree_Live"."ShowInSearch", "SiteTree_Live"."Sort", "SiteTree_Live"."HasBrokenFile", "SiteTree_Live"."HasBrokenLink", "SiteTree_Live"."ReportClass", "SiteTree_Live"."ParentID", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE E'SilverStripe\\CMS\\Model\\SiteTree' END AS "RecordClassName" FROM "SiteTree_Live" WHERE (MATCH ("SiteTree_Live"."Content") AGAINST ($1)) ORDER BY "SiteTree_Live"."Sort" ASC ERROR: syntax error at or near "AGAINST" LINE 5: WHERE (MATCH ("SiteTree_Live"."Content") AGAINST ($1)) ^
Not sure why this is happening. I’m trying to build a fulltext search of many of the page types on the site, but I need a side bar with checkboxes to filter various page types in/out of the results.
Any help greatly appreciated!