Clean up un-searchable fields

PM me for the code!

If you decide to make some field unsearchable, then CouchCMS doesn't add field's text data to fulltext search for any future pages. However for existing pages field's data is still available in search.

Code: Select all
<cms:editable name='test' type='text' searchable='0' /> => excludes field from search for new pages only.

I wrote a function that cleans up the database entries in table 'couch_fulltext'.
Smartly replaces old values - keeps the rest of the content untouched.

Code: Select all
<cms:call 'update_fulltext_exclude_unsearchable' masterpage="data.php"/>

This function processes editables with parameter searchable='0'. For each such field, text value is removed from fulltext search in db.
Run only once after editable was given that parameter. I may craft a permanent fix some day.