PHP code example of qdrant-labs / qdrant-laravel-scout

1. Go to this page and download the library: Download qdrant-labs/qdrant-laravel-scout library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

qdrant-labs / qdrant-laravel-scout example snippets


'model-settings' => [
    App\Models\Post::class => [
        'searchable-attributes' => ['title', 'body', 'tags'],
        'embedding' => [
            'attribute' => 'embedding',
            'dimensions' => 1536,
        ],
        'payload-indexes' => [
            'status' => 'keyword',
            'published_at' => 'integer',
        ],
    ],
],

public function toSearchableEmbedding(): string|array
{
    return $this->title."\n\n".$this->body;
}

'embedding' => [
    'attribute' => 'embedding',
    'dimensions' => 384,
    'driver' => 'qdrant',
    'model' => 'sentence-transformers/all-minilm-l6-v2',
],

$posts = Post::search('deploy laravel')
    ->where('status', 'published')
    ->paginate(15);

$posts = Post::search('how do I ship my app to production')
    ->semantic(minSimilarity: 0.7)
    ->get();

$posts = Post::search('deploy laravel')
    ->hybrid(textWeight: 1, semanticWeight: 2)
    ->get();

$posts = Post::search('')
    ->options([
        'filter' => ['must' => [['key' => 'tags', 'match' => ['value' => 'php']]]],
        'params' => ['hnsw_ef' => 128],
    ])
    ->get();
ini
SCOUT_DRIVER=qdrant
QDRANT_HOST=http://localhost:6333
QDRANT_API_KEY=
bash
php artisan vendor:publish --tag=scout-qdrant-config