I had big issues on a Craft 2 multilingual site with dozens of thousands of entries that were using Matrix fields. The site had become extremely slow (almost unusable), especially when recording new data.

This was certainly caused by the searchindex table which handled very massive records (that weren't particularly necessary for the search features of this project).

I am currently working on a Craft 3 site using PostgreSQL and fear the same kind of issues.


But since Craft 3, and following this post, there is now a RegisterElementSearchableAttributesEvent event that a plugin can listen to modify what gets saved to the search index table when an element is saved.


I tried to use this event in my CustomModule.php file using this simple test, in order to exclude every fields of the search index:

    function (RegisterElementSearchableAttributesEvent $event) {
        $event->attributes = [];

But unfortunately, this change nothing: on save, all the same fields are still saved in the searchindex table.


For a given Section, how can I exclude certains fields (specifically Matrix fields) from the search index on save (both from a CP or a front end entry save)?

Disclaimer: I'm a new to Module development

  • Are you sure you can disable the behavior? Because I don't see a way to prevent indexing the fields to be honest. It goes straight through without any events. Your event is for attributes related to the element, but your question is about the field layout and that's stored no matter what – Robin Schambach Oct 17 '18 at 17:19
  • Edit: Just for reference -> why don't you just uncheck the "Use this field’s values as search keywords?" Checkbox instead of trying to code something? – Robin Schambach Oct 18 '18 at 7:22
  • I'm not sure I can disabled the behavior, but according to this Brad's answer this is what I guess about excluding some fields. What checkbox are you talking about? I don't see it when configuring / editing my fields. – Romain Poirier Oct 18 '18 at 8:04
  • Ah sorry this is a new feature and does not exist yet in the current version of Craft. It will appear in the next major release – Robin Schambach Oct 18 '18 at 13:03
  • Oh, good to hear! How can I get this beta version to see if it could solve my problem? And do you have any idea when this feature will be publicly released? – Romain Poirier Oct 18 '18 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.