0

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.

Will
  • 4,498
  • 2
  • 38
  • 65

2 Answers2

1

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.

Guy Sartorelli
  • 313
  • 1
  • 8
  • thanks. this would be a good starting point but i was hoping for there to be a more out-of-the-box solution for such a basic function – Will Apr 27 '22 at 13:20
0

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.

Laurent PELE
  • 487
  • 3
  • 9
  • Concatenate my bocks in a text column how? by extending elemental? @laurent PELE - is your comment silverstripe specific or just a general observation? – Will Apr 20 '22 at 13:27