MYSQL based FulltextSearchable With Elemental blocks

74 Views Asked by At

Is it possible to use the mysql based fulltextsearchable functionality to search elemental blocks content?

Elemental has integration features with Solr, but I'm working on a few sites that are too small to justify running a server instance for search.

2

There are 2 best solutions below

2
On

Yes MySql full text search is efficient and reliable, just concatenate your blocks in a text column separated by spaces and index this column.

Avoiding using a search server like Solr should save you lots of pain.

2
On

The DNADesign\Elemental\Extensions\ElementalPageExtension provides a getElementsForSearch() method which is the elemental blocks concatenated and includes some configuration to customise it.

For this to work in a database-based search you'll need to store that (or something like it but why re-invent the wheel?) in the database. You can do this by declaring a new db field on the page and then using something like onBeforeWrite() on the page to actually store the data.

Be aware that you can save and publish blocks separately to the page though, which will complicate matters somewhat and could lead to stale data depending on how you handle this.