Download the PHP package ayaou/db-search-bundle without Composer
On this page you can find all versions of the php package ayaou/db-search-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ayaou/db-search-bundle
More information about ayaou/db-search-bundle
Files in ayaou/db-search-bundle
Package db-search-bundle
Short Description This bundle helps indexing and searching entities in a database
License MIT
Homepage https://github.com/ayaou/db-search-bundle
Informations about the package db-search-bundle
🔍 DB Search Bundle
📌 Overview
The DB Search Bundle helps you search text inside your database using Doctrine and Symfony.
✅ No need for Elasticsearch or other search engines!
✅ Works with your existing database!
⚠️ This is a simple and lightweight search solution for small to medium-sized projects. It does not support advanced features like fuzzy matching or search ranking.
📥 Installation
First, install the bundle using Composer:
Then, create the database table for indexing:
🗃️ Database Schema
The migration creates a table called db_search_index.
Here is an example for MySQL/MariaDB:
⚙️ Configuration
Define your indexes and entities in config/packages/db_search.yaml:
⚠️ Important: Each entity must have a getId() method that returns a unique ID.
🏷️ Indexing Rules
✅ You can create multiple indexes for different entities or fields.
✅ Each entity can have multiple fields indexed.
✅ Fields can be public properties or public methods.
✅ Indexed fields must return text, numbers, or boolean values (string, int, float, bool).
🔎 How Indexing & Search Works
For each field you configure in an entity, the bundle will:
- Take the field values.
- Concatenate them into one long text string, separated by spaces.
- Store the result in the
indexed_textcolumn.
When you search for a keyword, the bundle will:
- Look for the keyword inside the
indexed_textcolumn. - Return matching results based on the index configuration.
🔎 Usage
Searching the Database
Use the Searcher service (@db_search.searcher) to search in the database:
Regenerating the Search Index
Use the db-search:index:regenerate command to purge and rebuild the index for specific entities or indexes.
Reindex Everything
Reindex a Specific Index
Reindex a Specific Entity
Reindex a Specific Entity in a Specific Index
🏷️ This command purges existing index entries before reindexing.
🌟 Features
✅ Fast Search: Uses full-text search when available.
✅ Flexible Indexing: Supports multiple indexes and entities.
✅ Customizable: You can modify search behavior using Symfony services.
🔮 Future Improvements
🔹 Support for More Databases like PostgreSQL, SQLServer, Oracle.
🔹 Faster indexation with asynchronous indexing using Symfony Messenger.
🔹 Smarter Search with phonetic matching and synonyms.
🔹 Better Ranking to show more relevant results first.
💡 Contributions Welcome!
If you find a bug or have an idea for improvement, please create an issue or pull request. 🚀
All versions of db-search-bundle with dependencies
symfony/console Version ^6.4
symfony/event-dispatcher Version ^6.4
symfony/dependency-injection Version ^6.4
doctrine/doctrine-bundle Version *
doctrine/orm Version *