in-square / opendxp-simple-search-bundle
MySQL FULLTEXT based frontend search index for OpenDXP (Documents + DataObjects).
Package info
github.com/in-square/opendxp-simple-search-bundle
Type:opendxp-bundle
pkg:composer/in-square/opendxp-simple-search-bundle
v1.0.0
2026-03-30 13:33 UTC
Requires
- php: ^8.3
- doctrine/dbal: ^3.6 || ^4.0
- open-dxp/opendxp: ^1.0
- symfony/console: ^7.4
- symfony/framework-bundle: ^7.4
- symfony/messenger: ^7.4
- symfony/routing: ^7.4
This package is not auto-updated.
Last update: 2026-04-18 06:24:34 UTC
README
Bundle for full-text search in OpenDXP 11 using MySQL FULLTEXT index
Install the bundle
composer require in-square/opendxp-simple-search-bundle
Create a configuration
touch config/packages/in_square_opendxp_simple_search.yaml
Basic configuration
#config/packages/insquare_opendxp_simple_search.yaml in_square_opendxp_simple_search: table_name: 'insquare_search_index' locales: ['pl', 'en'] sites: [0] index_documents: true index_objects: true max_content_length: 20000 snippet_length: 220 use_boolean_mode: true min_search_length: 3
Register bundle in bundles.php
<?php // config/bundles.php return [ // other bundles InSquare\OpendxpSimpleSearchBundle\InSquareOpendxpSimpleSearchBundle::class => ['all' => true], ];
Create object extractors
isValid() allows you to skip indexing for a given object/locale combination.
<?php // src/Search/Extractor/ProductExtractor.php namespace App\Search\Extractor; use InSquare\OpendxpSimpleSearchBundle\Service\Extractor\ObjectContentExtractorInterface; use InSquare\OpendxpSimpleSearchBundle\Service\Text\TextNormalizer; use OpenDXP\Model\DataObject\Concrete; use OpenDXP\Model\DataObject\Product; final readonly class ProductExtractor implements ObjectContentExtractorInterface { public function getSupportedClass(): string { return Product::class; } public function isValid(Concrete $object, string $locale): bool { return $object instanceof Product && $object->isPublished(); } public function extractContent(Concrete $object, string $locale): ?string { if (!$object instanceof Product) { return null; } return TextNormalizer::join([ $object->getName($locale), $object->getDescription($locale), $object->getSku(), ]); } }
Register extractor as a tagged service
#config/services.yaml services: App\Search\Extractor\ProductExtractor: tags: - { name: 'insquare.search.object_extractor' }
Bundle will automatically detect the extractor and assign it to the Product class.
Run the installation command
bin/console insquare:search:install
Index all items
bin/console insquare:search:reindex
Symfony Messenger
Start the messenger worker
bin/console messenger:consume async -vv
Route bundle message to async transport (recommended):
# config/packages/messenger.yaml framework: messenger: routing: InSquare\OpendxpSimpleSearchBundle\Message\IndexElementMessage: async
Use in the controller
use InSquare\OpendxpSimpleSearchBundle\Service\SearchService; class SearchController extends AbstractController { public function __construct( private readonly SearchService $searchService ) {} #[Route('/search')] public function search(Request $request): Response { $query = $request->query->get('q'); $locale = $request->getLocale(); $results = $this->searchService->search( query: $query, locale: $locale, site: 0, limit: 20, offset: 0 ); return $this->render('search/results.html.twig', [ 'results' => $results, 'query' => $query ]); } }