Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Scout Advanced Meilisearch Laravel Package

alejandroakbal/laravel-scout-advanced-meilisearch

Laravel Scout extension adding advanced query builder filters (comparisons, grouped where/orWhere, between, notIn) plus two compatible drivers: meilisearch_advanced for better Meilisearch filtering/total counts and collection_advanced for in-memory testing.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Search Functionality: The package extends Laravel Scout’s capabilities by integrating Meilisearch, a lightweight, fast, and typo-tolerant search engine. This is a strong fit for applications requiring full-text search, typo resilience, and relevance tuning without the complexity of Elasticsearch.
  • Laravel Scout Compatibility: Since it’s a Scout driver, it integrates seamlessly with Laravel’s built-in Scout features (e.g., search(), toSearchableArray(), forceSync()), reducing boilerplate for search-heavy applications.
  • Real-Time Updates: Meilisearch’s near-instant indexing aligns well with Laravel’s active record pattern, enabling real-time search updates without heavy batch processing.
  • Alternative to Algolia/Scout Defaults: If the app currently uses Scout’s default database driver or Algolia, this could reduce costs (Meilisearch is open-source) while improving performance.

Integration Feasibility

  • Minimal Code Changes: Replacing Scout’s default driver with this package requires only configuration changes (e.g., config('scout.meilisearch')) and minimal adjustments to existing search logic.
  • Meilisearch Setup: Requires deploying Meilisearch (self-hosted or cloud), which adds operational overhead but is manageable for teams familiar with containerization (Docker) or cloud services.
  • Hybrid Search Support: The package supports hybrid search (combining Meilisearch with other drivers), which is useful for phased rollouts or A/B testing.

Technical Risk

  • Meilisearch Dependency: Tight coupling with Meilisearch means downtime or version mismatches could disrupt search functionality. Mitigation: Use feature flags to toggle between drivers during transitions.
  • Indexing Strategy: Meilisearch requires explicit schema definitions (e.g., attributesForFaceting, searchableAs). Misconfigurations could lead to poor search relevance or performance. Risk: Teams unfamiliar with Meilisearch may need training or documentation.
  • Scaling Limits: Meilisearch is optimized for small-to-medium datasets (sub-10M records). For larger scales, consider sharding or evaluating Elasticsearch. Risk: May require rearchitecting if search volume grows unexpectedly.
  • Laravel Scout Version Lock: The package may lag behind Laravel Scout updates. Risk: Compatibility issues if Scout introduces breaking changes. Mitigation: Monitor upstream Scout releases and test early.

Key Questions

  1. Current Search Stack:
    • What is the existing search solution (e.g., Scout DB driver, Algolia, custom SQL)?
    • How critical is search to core user flows (e.g., e-commerce, content discovery)?
  2. Meilisearch Infrastructure:
    • Will Meilisearch be self-hosted (e.g., Docker, Kubernetes) or cloud-managed (e.g., Meilisearch.com)?
    • Are there budget constraints for hosting/operating Meilisearch?
  3. Data Volume and Complexity:
    • What is the expected size of the searchable dataset (records + fields)?
    • Are there faceted search, typo tolerance, or synonym requirements?
  4. Team Expertise:
    • Does the team have experience with Meilisearch or similar search engines?
    • Is there capacity to debug search relevance tuning (e.g., custom ranking rules)?
  5. Fallback Strategy:
    • Should the app support a fallback to Scout’s DB driver or another engine during Meilisearch outages?
  6. Long-Term Scalability:
    • Are there plans to scale beyond Meilisearch’s current limits (e.g., >10M records)?
    • Has the team evaluated alternatives like Elasticsearch or Typesense for future needs?

Integration Approach

Stack Fit

  • Laravel Ecosystem: Perfect fit for Laravel apps using Scout. Leverages Scout’s HasSearchable trait, Searchable models, and ScoutServiceProvider.
  • PHP Compatibility: Works with PHP 8.0+ (aligns with Laravel 9+/10+). No major PHP version constraints.
  • Database Agnostic: Meilisearch decouples search from the primary database, improving performance for read-heavy workloads.
  • Tooling Synergy:
    • Laravel Telescope: Can monitor search queries and performance.
    • Laravel Horizon: Useful for managing async search indexing jobs.

Migration Path

  1. Assessment Phase:
    • Audit existing search queries and models to identify Scout-specific logic (e.g., custom toSearchableArray()).
    • Benchmark current search performance (latency, relevance) as a baseline.
  2. Setup Meilisearch:
    • Deploy Meilisearch (e.g., Docker: docker run -p 7700:7700 getmeilisearch/meilisearch).
    • Configure environment variables (e.g., MEILISEARCH_HOST, MEILISEARCH_KEY).
  3. Configure Scout:
    • Update config/scout.php to use the meilisearch driver:
      'driver' => env('SCOUT_DRIVER', 'meilisearch'),
      
    • Publish and configure the package’s config:
      php artisan vendor:publish --provider="Alejandroakbal\LaravelScoutAdvancedMeilisearch\MeilisearchServiceProvider"
      
  4. Model Adjustments:
    • Ensure models use HasSearchable and define toSearchableArray().
    • Add Meilisearch-specific attributes (e.g., searchableAs, attributesForFaceting):
      use Alejandroakbal\LaravelScoutAdvancedMeilisearch\HasAdvancedSearchable;
      
      class Product extends Model implements HasAdvancedSearchable
      {
          public function toSearchableArray()
          {
              return [
                  'title' => $this->title,
                  'description' => $this->description,
              ];
          }
      
          public function searchableAs()
          {
              return 'products';
          }
      
          public function toMeilisearchArray()
          {
              return [
                  'facets' => ['category', 'price_range'],
              ];
          }
      }
      
  5. Testing:
    • Test search functionality in staging with a subset of data.
    • Validate faceted search, typo tolerance, and relevance.
    • Load test with production-like query volumes.
  6. Phased Rollout:
    • Use Scout’s hybrid search to gradually shift traffic to Meilisearch:
      $results = Product::search('query')->meilisearch()->get();
      
    • Monitor errors and performance metrics (e.g., query latency, index size).

Compatibility

  • Laravel Scout Features:
    • Supports search(), cursor(), paginate(), and forceSync().
    • Works with Scout’s chunking for large datasets.
  • Meilisearch-Specific Features:
    • Typo Tolerance: Built-in via Meilisearch’s typoTolerance parameter.
    • Faceting: Enable via toMeilisearchArray().
    • Custom Ranking: Use Meilisearch’s rankingRules for relevance tuning.
  • Limitations:
    • No native support for geospatial search (unless using Meilisearch’s experimental features).
    • Analyzers: Limited to Meilisearch’s built-in analyzers (e.g., no custom NLP models out of the box).

Sequencing

  1. Pre-Migration:
    • Document current search queries and dependencies.
    • Set up Meilisearch infrastructure (hosting, backups).
    • Train team on Meilisearch basics (indexing, querying).
  2. Configuration:
    • Update Scout driver and publish package config.
    • Configure models with searchableAs and toMeilisearchArray.
  3. Testing:
    • Test in isolation (e.g., php artisan scout:import "App\Models\Product").
    • Validate hybrid search fallbacks.
  4. Deployment:
    • Roll out to a percentage of users (e.g., via feature flag).
    • Monitor Meilisearch metrics (CPU, memory, query latency).
  5. Post-Launch:
    • Optimize indexes (e.g., adjust searchableAs for performance).
    • Set up alerts for Meilisearch health (e.g., high latency).

Operational Impact

Maintenance

  • Package Updates:
    • Monitor the package for updates (currently unmaintained; risk: may require forking).
    • Watch for Laravel Scout breaking changes that could affect compatibility.
  • Meilisearch Maintenance:
    • Index Optimization: Periodically review and optimize Meilisearch indexes (e.g., remove unused attributes).
    • Backups: Implement automated backups for Meilisearch data (e.g., meilisearch backup CLI).
    • Version Upgrades: Test Meilisearch upgrades in staging before production updates.
  • Logging:
    • Log search queries and errors to identify patterns (e.g., slow queries, failed syncs).
    • Use Meilisearch’s built-in analytics for query insights.

Support

  • Debugging:
    • Common Issues:
      • Slow queries: Check Meilisearch’s search endpoint for bottlenecks (e.g., large `attributes
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle