- How do I enable advanced Meilisearch queries in Laravel Scout?
- Set the Scout driver to `meilisearch_advanced` in your `config/scout.php` file. This unlocks extended query methods like `whereBetween`, `orWhereIn`, and comparison operators (`<=`, `>=`). For testing, use `collection_advanced` to mimic Meilisearch behavior in-memory.
- What Laravel versions does this package support?
- This package works with Laravel 9+ and 10+, requiring PHP 8.0+. Ensure your Laravel Scout version is compatible with the package’s requirements, as Scout updates may introduce breaking changes.
- Can I use this package alongside Algolia or Scout’s default database driver?
- No, this package replaces Scout’s default driver. However, you can use the `collection_advanced` driver for testing while keeping `meilisearch_advanced` for production. For hybrid setups, consider feature flags to toggle between drivers.
- How does the `collection_advanced` driver work, and when should I use it?
- The `collection_advanced` driver loads all searchable data into memory, simulating Meilisearch’s behavior for testing. Use it during development to validate filtering, sorting, and advanced queries without requiring a Meilisearch instance.
- Does this package fix Meilisearch’s total count issue when using `->query()`?
- Yes, the `meilisearch_advanced` driver corrects Meilisearch’s default behavior of fetching the entire dataset to calculate totals. It now accurately returns the count without overloading your search index.
- How do I handle indexed arrays or nested fields in Meilisearch with this package?
- The `meilisearch_advanced` driver fully supports Meilisearch’s indexed arrays and nested fields. Ensure your model’s `toSearchableArray()` method returns the correct structure, and define `attributesForFaceting` or `searchableAs` in your Meilisearch schema.
- What are the performance implications of using Meilisearch vs. Scout’s default database driver?
- Meilisearch is significantly faster for full-text search, typo tolerance, and faceted filtering compared to Scout’s database driver. However, self-hosting Meilisearch adds operational overhead. For small datasets, the `collection_advanced` driver may suffice for testing.
- Can I use this package for large-scale applications (e.g., 10M+ records)?
- Meilisearch scales well up to ~10M records, but beyond that, consider sharding or alternatives like Elasticsearch. Monitor your dataset size and query performance; the `meilisearch_advanced` driver optimizes for accuracy and speed within Meilisearch’s limits.
- How do I test advanced queries like `whereBetween` or `orWhereIn` without a Meilisearch instance?
- Use the `collection_advanced` driver in your tests. It supports all extended query methods and mimics Meilisearch’s behavior, allowing you to validate logic without external dependencies. Example: Set the driver in `phpunit.xml` or `.env.testing`.
- What if Meilisearch goes down? Can I fallback to another driver?
- This package doesn’t include built-in fallback logic, but you can implement it using feature flags or Laravel’s Scout’s `shouldSearchUsing` method. For example, switch to the database driver or cache results during outages, though this may impact search relevance.