FulltextSearchable::enable([SiteTree::class]); // this works (files not showing any more)
Product::add_extension("FulltextSearchable('Title')"); // doesn't work, please see error message below
When I do myproject.local/dev/build?flush, I get the following error:
ERROR [Emergency]: Uncaught InvalidArgumentException: Object::add_extension() - Can’t find extension class for “FulltextSearchable” IN GET /dev/build?flush
I’m guessing you may need to pass the fully qualified class name of FulltextSearchable into the add_extension() method, because in the extensible class, it’s checking that parameter with class_exists()
That definitely solved the dev/build error and I got “Index Product.SearchFields: created as fulltext (“Title”)” , but unfortunately when I search for a product, it doesn’t come up in the search result.
The SearchForm class is hardcoded to only search in the Page and File classes. So, you’ll probably need to replace that class in order to add your own dataobject to the search. (You can do this using Injector fairly easily). The SearchForm class is actually pretty simple, so hopefully it won’t be a big chore to do.
Hi Tim,
Thanks for your help.
After a lot of googling I finally found this hidden gem: https://github.com/axllent/silverstripe-ftsearch which did the trick.
Just mention it here in case somebody else has the same problem.