1. Go to this page and download the library: Download aloko/elasticquent5 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/ */
aloko / elasticquent5 example snippets
use Aloko\Elasticquent\ElasticquentTrait;
class Book extends Eloquent {
use ElasticquentTrait;
}
return array(
/*
|--------------------------------------------------------------------------
| Default Index Name
|--------------------------------------------------------------------------
|
| This is the index name that Elastiquent will use for all
| Elastiquent models.
*/
'default_index' => 'my_custom_index_name',
);
function getTypeName()
{
return 'my_books';
}
$client = new \Elasticsearch\Client();
$params = array(
'index' => 'default',
'type' => 'books'
);
$params['body']['query']['match']['title'] = 'Moby Dick';
$collection = new Aloko\Elasticquent\ElasticquentResultCollection($client->search($params), new Book);