1. Go to this page and download the library: Download ritey/laravel-manticore 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/ */
ritey / laravel-manticore example snippets
'driver' => 'manticore',
use Laravel\Scout\Searchable;
class Post extends Model
{
use Searchable;
public function searchableAs(): string
{
return 'posts_index';
}
public function toSearchableArray(): array
{
return [
'title' => $this->title,
'body' => $this->body,
'metadata' => $this->metadata,
'embedding' => $this->embedding,
];
}
}
Post::search('open education')->get();
use Ritey\LaravelManticore\FilterBuilder;
$filters = (new FilterBuilder)
->where('metadata.topic', 'ai')
->whereRange('score', ['gte' => 0.6]);
Post::search('ai in education')
->tap(function ($builder) use ($filters, $vector) {
$builder->vector = $vector;
$builder->filterBuilder = $filters;
$builder->similarity = 'cosine';
})
->get();