PHP code example of babenkoivan / elastic-scout-driver-plus
1. Go to this page and download the library: Download babenkoivan/elastic-scout-driver-plus 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/ */
babenkoivan / elastic-scout-driver-plus example snippets
use Elastic\ScoutDriverPlus\Support\Query;
// using a query builder
$query = Query::match()
->field('title')
->query('My book')
->fuzziness('AUTO');
// using a raw query
$query = [
'match' => [
'title' => [
'query' => 'My book',
'fuzziness' => 'AUTO'
]
]
];
class Book extends Model
{
use Elastic\ScoutDriverPlus\Searchable;
public function searchableRouting()
{
return $this->user->id;
}
}
class Book extends Model
{
use Elastic\ScoutDriverPlus\Searchable;
public function toSearchableArray()
{
return [
'title' => $this->title,
'price' => $this->price,
'author' => $this->author->only(['name', 'phone_number']),
];
}
}
class Book extends Model
{
use Elastic\ScoutDriverPlus\Searchable;
public function toSearchableArray()
{
return [
'title' => $this->title,
'price' => $this->price,
'author' => $this->author->only(['name', 'phone_number']),
];
}
public function searchableWith()
{
return ['author'];
}
}
class Book extends Model
{
use Elastic\ScoutDriverPlus\Searchable;
public function searchableConnection(): ?string
{
return 'books';
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.