- How do I migrate from Laravel Scout’s default database driver to jeroen-g/explorer?
- Update your `config/scout.php` to set the `driver` to `explorer` and ensure your models use the `Searchable` trait. Run `php artisan scout:import` to sync existing data to Elasticsearch. The package maintains Scout’s familiar methods like `search()`, `searchWhere()`, and `paginate()`, so no major refactoring is needed.
- Does jeroen-g/explorer support Elasticsearch 7.x, or is it limited to 8.x?
- The package requires Elasticsearch 8.x (as of v4.0.0) due to dependency updates. If you’re on Elasticsearch 7.x, you’ll need to upgrade your cluster or use an alternative like `tightenco/searchable` or `meilisearch/meilisearch`. Check compatibility with your infrastructure before adopting.
- Can I use custom analyzers or mappings with jeroen-g/explorer?
- Yes, the package allows full control over Elasticsearch mappings and analyzers via `config/explorer.php`. Define custom fields, analyzers, or settings in the `mappings` array, and Explorer will apply them during index creation. For advanced use cases, you can also extend the driver with custom logic.
- How do I handle real-time indexing for critical data updates?
- Scout’s default `scout:import` runs in batches, which may introduce latency. For real-time updates, use `scout:flush` to force immediate reindexing or trigger indexing via model observers or Laravel queues. The package also supports bulk indexing for efficiency.
- What Laravel and PHP versions does jeroen-g/explorer support?
- The package requires Laravel 10+ and PHP 8.2+ (as of v4.4.0). If you’re on an older stack, consider downgrading to an earlier version of Explorer or evaluating alternatives like `spatie/laravel-scout-elasticsearch` for broader compatibility.
- How do I test aggregations or complex queries locally without Elasticsearch?
- Use Laravel’s `fake()` method to mock Elasticsearch responses in tests. The package provides helpers to simulate aggregations, terms queries, and other DSL features. Example: `Explorer::fake()->withResponse([...])`. This is useful for unit testing without a live cluster.
- Can I use jeroen-g/explorer with non-Scout models or custom search logic?
- No, the package is tightly coupled with Laravel Scout’s contracts (e.g., `toSearchableArray()`, `shouldBeSearchable()`). If you need custom search logic outside Scout, consider building a standalone Elasticsearch client or using a package like `elasticsearch/elasticsearch` directly.
- What’s the best way to manage index aliases for zero-downtime updates?
- Explorer automatically handles aliases via Scout’s `scout:index` and `scout:delete-index` commands. Test rollback procedures in staging by manually updating aliases and verifying data integrity. Always back up your index before major updates.
- How do I handle production failures if Elasticsearch goes down?
- The package supports graceful degradation, but for resilience, implement redundancy (e.g., multi-region clusters) or fallback strategies like caching results. Use Laravel’s `try-catch` blocks around Scout queries and log failures for monitoring.
- Are there alternatives to jeroen-g/explorer for Laravel Elasticsearch integration?
- Yes, alternatives include `tightenco/searchable` (older but widely used), `spatie/laravel-scout-elasticsearch` (supports ES 7.x), or `meilisearch/meilisearch` (simpler but less feature-rich). Choose based on your Elasticsearch version, Laravel compatibility, and need for advanced features like aggregations.