Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

FulltextSearchable SiteTree defaultColumns


Go to End


2 Posts   1440 Views

Avatar
PeterLu

Community Member, 8 Posts

18 April 2016 at 6:56pm

Hi,

The default search columns for SiteTree is set to
'SiteTree' => '"Title","MenuTitle","Content","MetaDescription"', (/framework/search/FulltextSearchable.php)

I tried to set it to only have Title and Content.
'SiteTree' => '"Title","Content"',
When I run /dev/build?flush, it says

Index SiteTree.SearchFields: changed to fulltext ("Title","Content") (from fulltext ("Title","MenuTitle","Content","MetaDescription"))
Index SiteTree_Live.SearchFields: changed to fulltext ("Title","Content") (from fulltext ("Title","MenuTitle","Content","MetaDescription"))
Index SiteTree_versions.SearchFields: changed to fulltext ("Title","Content") (from fulltext ("Title","MenuTitle","Content","MetaDescription"))

Then When I try to do a search, it throws a DB error:
[User Error] Couldn't run query: SELECT DISTINCT ClassName, "SiteTree_Live"."ID", ParentID, Title, MenuTitle, URLSegment, Content, LastEdited, Created, _utf8'' AS "Filename", _utf8'' AS "Name", MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('test') + MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('test') AS "Relevance", CanViewType FROM "SiteTree_Live" WHERE ( MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('test*' IN BOOLEAN MODE) + MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('test*' IN BOOLEAN MODE) AND ShowInSearch 0) ORDER BY "Relevance" DESC LIMIT 0, 10 Can't find FULLTEXT index matching the column list
GET /search/SearchForm?Search=test

Any ideas?
Why the query still contains MenuTitle & MetaDescription ?

Peter

Avatar
PeterLu

Community Member, 8 Posts

18 April 2016 at 7:07pm

Found it.
I also need to modify /framework/model/MySQLDatabase.php