jeroen-g/explorer
A Laravel Scout driver for Elasticsearch and OpenSearch. Index and search Eloquent models with configurable mappings, analyzers, and settings, plus support for queues, bulk indexing, and advanced queries—ideal for scalable full‑text search.
Strengths:
Explorer classes. Reduces controller bloat and enforces consistency.toSearchableArray(), shouldBeSearchable()), minimizing refactoring for teams already using Scout. Supports both Eloquent and query builder data sources.->where('price', '>', 100)), lowering the barrier for non-Elasticsearch experts.scout:index, scout:delete-index) and alias support enable zero-downtime deployments, critical for production systems.Potential Misalignment:
scout:import) introduce a delay between database writes and search indexes. For use cases requiring sub-second sync (e.g., live chat), consider supplementing with webhooks or triggers.Elasticsearch Version Lock-In:
README and provide a migration path for teams on ES7 (e.g., "Use v3.x until your cluster is upgraded").Breaking Changes:
Performance Pitfalls:
text fields without analyzers) or unoptimized queries (e.g., wildcards on large datasets) can degrade performance.config/explorer.php and include a query performance checklist in docs (e.g., "Avoid wildcard queries on fields >10k docs; use keyword for exact matches").Operational Debt:
Search Workload Profile:
index.refresh_interval).Data Model Complexity:
english stemmer)?Infrastructure Constraints:
Team Expertise:
Cost vs. Benefit:
Future-Proofing:
Laravel Ecosystem:
database, meilisearch) with Elasticsearch. Works alongside Scout’s model observers, search() method, and scout:import commands.scout:index, scout:flush) with Elasticsearch-specific enhancements (e.g., alias management).Elasticsearch Stack:
elasticsearch/elasticsearch PHP client (v8+), ensuring compatibility with Elasticsearch 8.x.config/explorer.php or runtime overrides, supporting dynamic schemas (e.g., per-model mappings).UI Layer:
| Phase | Action Items | Risks | Mitigation |
|---|---|---|---|
| Preparation | 1. Audit current search queries (SQL LIKE, Algolia, etc.). |
Legacy queries may not map 1:1 to Elasticsearch. | Document gaps and plan for rework (e.g., "Fuzzy search" → match query). |
| 2. Upgrade Laravel to 10.x and Scout to 11.x (if not already). | Breaking changes in Scout/Laravel. | Test upgrades in a staging environment. | |
| 3. Set up Elasticsearch (Docker or cloud). | Cluster misconfiguration. | Use the package’s default docker-compose.yml (if provided) or official guides. |
|
| Configuration | 4. Define mappings in config/explorer.php. |
Incorrect mappings lead to poor performance. | Start with defaults, then optimize (e.g., add keyword sub-fields for exact matches). |
5. Configure Scout to use the Explorer driver in config/scout.php. |
Driver misconfiguration. | Verify with php artisan scout:config. |
|
| Data Migration | 6. Import existing data: php artisan scout:import "App\Models\Product". |
Large datasets may time out. | Use chunking or queue the import job. |
| Testing | 7. Write integration tests using the mocking feature. | Mocks may not cover all edge cases. | Test with a staging Elasticsearch cluster. |
| Deployment | 8. Deploy with zero-downtime: Update aliases via queue jobs. | Alias update failures. | Monitor queue jobs and roll back if needed. |
| Optimization | 9. Profile slow queries with Kibana/Dev Tools. | Unoptimized queries. | Use the package’s logging and Explorer classes to refine queries. |
How can I help you explore Laravel packages today?