All Projects → meilisearch → Meilisearch Laravel Scout

meilisearch / Meilisearch Laravel Scout

Licence: mit
MeiliSearch integration for Laravel Scout

Projects that are alternatives of or similar to Meilisearch Laravel Scout

Validatorjs
A data validation library in JavaScript for the browser and Node.js, inspired by Laravel's Validator.
Stars: ✭ 1,534 (+289.34%)
Mutual labels:  laravel, client
Pipedrive
Complete Pipedrive API client for PHP
Stars: ✭ 138 (-64.97%)
Mutual labels:  laravel, client
Deeply
PHP client for the DeepL.com translation API (unofficial)
Stars: ✭ 152 (-61.42%)
Mutual labels:  laravel, client
Btorrent
🌐 Fully-featured WebTorrent Client
Stars: ✭ 388 (-1.52%)
Mutual labels:  client
Stream Parser
⚡ PHP7 / Laravel Multi-format Streaming Parser
Stars: ✭ 391 (-0.76%)
Mutual labels:  laravel
Pushnotification
PHP and Laravel Package to send push notifications to Android and IOS devices.
Stars: ✭ 395 (+0.25%)
Mutual labels:  laravel
Location
Detect a users location by their IP Address.
Stars: ✭ 397 (+0.76%)
Mutual labels:  laravel
I Educar
Lançando o maior software livre de educação do Brasil!
Stars: ✭ 388 (-1.52%)
Mutual labels:  laravel
Graphql Ws
Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client.
Stars: ✭ 398 (+1.02%)
Mutual labels:  client
Laravel Schedule Monitor
Monitor scheduled tasks in a Laravel app
Stars: ✭ 393 (-0.25%)
Mutual labels:  laravel
Node Vault
Client for HashiCorp's Vault
Stars: ✭ 391 (-0.76%)
Mutual labels:  client
Mumble
Mumble is an open-source, low-latency, high quality voice chat software.
Stars: ✭ 4,418 (+1021.32%)
Mutual labels:  client
Huejay
Philips Hue client for Node.js
Stars: ✭ 395 (+0.25%)
Mutual labels:  client
Laravel Csp
Set content security policy headers in a Laravel app
Stars: ✭ 388 (-1.52%)
Mutual labels:  laravel
Larapi
An API-friendly fork of Laravel. Authentication, error handling, resource filtering, sorting, pagination and much more included
Stars: ✭ 397 (+0.76%)
Mutual labels:  laravel
Popcorn Time Desktop
🍿 🕐 🎞 A Modern Popcorn Time Client
Stars: ✭ 389 (-1.27%)
Mutual labels:  client
Comments
Native comments for your Laravel application.
Stars: ✭ 390 (-1.02%)
Mutual labels:  laravel
Laravel Ueditor
UEditor integration for Laravel.
Stars: ✭ 392 (-0.51%)
Mutual labels:  laravel
Stellarterm
Advanced web based trading client for the Stellar network. 📈📊💹💱
Stars: ✭ 392 (-0.51%)
Mutual labels:  client
Zhihu App
laravel-vue-zhihu ✨
Stars: ✭ 395 (+0.25%)
Mutual labels:  laravel

MeiliSearch Laravel Scout

MeiliSearch Laravel Scout

MeiliSearch | Documentation | Slack | Roadmap | Website | FAQ

Latest Stable Version Actions Status License Bors enabled

⚡ The MeiliSearch driver for Laravel Scout

MeiliSearch Laravel Scout is a MeiliSearch driver for Laravel.

MeiliSearch is an open-source search engine. Discover what MeiliSearch is!

Table of Contents

📖 Documentation

See our Documentation or our API References.

Also, take a look at the Wiki of this repository!

🔧 Installation

Install the Plugin

composer require meilisearch/meilisearch-laravel-scout

Install the HTTP Client

You could use any PSR-18 compatible client to use with this SDK. No additional configurations are required.
A list of compatible HTTP clients and client adapters can be found at php-http.org.

If you use Laravel 8 you can skip this section as laravel pre-install Guzzle 7 by default.

Guzzle 7:

composer require guzzlehttp/guzzle

If you already have guzzle installed with a version < 7, don't forget to update the version inside your composer.json

"require": {
  "guzzlehttp/guzzle": "^7.0"
}

Guzzle 6:

composer require php-http/guzzle6-adapter

Symfony Http Client:

composer require symfony/http-client nyholm/psr7

Curl:

composer require php-http/curl-client nyholm/psr7

Export Configuration

php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
php artisan vendor:publish --provider="Meilisearch\Scout\MeilisearchServiceProvider" --tag="config"

Update the .env file

SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://127.0.0.1:7700
MEILISEARCH_KEY=masterKey

Run MeiliSearch

There are many easy ways to download and run a MeiliSearch instance.

For example, if you use Docker:

docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey

NB: you can also download MeiliSearch from Homebrew or APT.

🚀 Getting Started

Indexes

Create an Index

// Create an index
php artisan scout:index books
// Create an index and give the primary-key
php artisan scout:index books --key book_id

Add Documents

<?php

use Laravel\Scout\Searchable;

class Book extends Model
{
    use Searchable;
}
<?php

class BookController extends Controller
{
    public function store()
    {
        $book = new Book();
        $book->title = 'Pride and Prejudice';
        ...
        $book->save();
    }
}

You can also import all your table to meilisearch by using the artisan command:

php artisan scout:import "App\Book"

Search in an Index

class BookController extends Controller
{
    public function search()
    {
        // MeiliSearch is typo-tolerant:
        Book::search('harry pottre')->get();
        // Or if you want to get the result from meilisearch:
        Book::search('harry pottre')->raw();
    }
}

Delete Documents

class BookController extends Controller
{
    public function destroy($id)
    {
        // Delete one document
        Book::find($id)->delete();
        // Delete several documents
        Book::destroy([1, 42]);
        // Delete all documents /!\
        Book::query()->delete();
    }
}

or you can use the artisan command to delete all documents from an index:

php artisan scout:flush "App\Book"

Delete an Index

php artisan scout:index -d books

Search

Custom Search

All the supported options are described in the search parameters section of the documentation.

class BookController extends Controller
{
    public function customSearch()
    {
        Book::search('prince', function (Indexes $meilisearch, $query, $options) {
            $options['filters'] = 'author="Antoine de Saint-Exupéry"';

            return $meilisearch->search($query, $options);
        })->take(3)->get();
    }
}

Pagination

class BookController extends Controller
{
    public function search()
    {
        Book::search('mustang')->paginate();
        // with a limit of items per page:
        Book::search('mustang')->paginate(5);
        // using meilisearch response:
        Book::search('mustang')->paginateRaw();
    }
}

🤖 Compatibility with MeiliSearch

This package only guarantees the compatibility with the version v0.19.0 of MeiliSearch.

💡 Learn More

If you're not familiar with MeiliSerach yet, the following sections may interest you:

💡 You can use more advance function by reading the documentation of MeiliSearch PHP Client.

👍 This package is a custom engine of Laravel Scout.

Development Workflow and Contributing

Any new contribution is more than welcome in this project!

If you want to know more about the development workflow or want to contribute, please visit our contributing guidelines for detailed instructions!


MeiliSearch provides and maintains many SDKs and Integration tools like this one. We want to provide everyone with an amazing search experience for any kind of project. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the integration-guides repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].