Skip to content

Helper: Search

The search library included in XELOS delivers search functionality across all modules via an SQL or ELASTIC SEARCH interface.

Adding documents to the search index

If you already have a module with a document model, the easiest way to add your document data to the central search is by implementing the SearchableDocumentModelInterface in your DocumentModel:

MyDocumentModel.php (Example)

class MyDocumentModel extends DocumentModel implements SearchableDocumentModelInterface {

    public function updateSearchIndex(SearchIndexRecord $searchIndexRecord): SearchIndexRecord {

        // Set Base-Index

        // If additional language versions are available -> Add them as translated content

        // Return index record
        return $searchIndexRecord;

You need to make sure that your document model is registered for index_events in your config.yml:

    registered_for: ['search', 'index_events']