# Laravel Scout

What is Laravel Scout?

Laravel Scout is a full-text search solution for Eloquent models. It provides a simple, driver-based approach to adding search functionality to your Laravel application, supporting drivers like Algolia and Meilisearch.

---

## Origin

Scout was introduced to make integrating full-text search into Laravel applications straightforward, leveraging external search engines for powerful indexing and querying.

---

## Why is Laravel Scout Used?

1. **Simplifies Full-Text Search**: Makes implementing search features easy with minimal configuration.
2. **Supports Scalable Drivers**: Works with search engines like Algolia and Meilisearch for large datasets.
3. **Integrates with Eloquent**: Syncs seamlessly with Eloquent models for effortless indexing.

---

## Best Practices

1. **Choose the Right Driver**: Select a search engine driver that suits your application needs.
2. **Index Only Necessary Data**: Avoid indexing sensitive or unnecessary fields.
3. **Optimize Indexing**: Use batch processing for large datasets.

---

## Example in Action

Install Scout:

```bash
composer require laravel/scout
```

Configure a driver (e.g., Algolia) in `.env`:

```env
SCOUT_DRIVER=algolia
ALGOLIA_APP_ID=your-app-id
ALGOLIA_SECRET=your-secret-key
```

Add the `Searchable` trait to a model:

```php
namespace App\Models;

use Laravel\Scout\Searchable;

class Post extends Model
{
    use Searchable;
}
```

Search the model:

```php
$posts = Post::search('Laravel')->get();
```

Read this definition in a browser: https://ranetrace.com/glossary/laravel-scout
