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)

use XELOS\Framework\Module\Model\DocumentModel;
use XELOS\Framework\Core\Interfaces\SearchableDocumentModelInterface;
use XELOS\Modules\Search\SearchIndexRecord;

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']