PHP code example of almeida / laravel-elasticsearch
1. Go to this page and download the library: Download almeida/laravel-elasticsearch 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/ */
almeida / laravel-elasticsearch example snippets
/**
* Acme\Search\MovieDocument
*/
class MovieDocument extends \Almeida\LaravelElasticSearch\ElasticDocumentAbstract
{
protected $index = 'movie_cluster';
protected $type = 'movies';
public function setId($movie) {
return $movie->id;
}
}
$options = [];
$options['transformer'] = 'Acme\MovieTransformer';
$document = new \Acme\Search\MovieDocument($options);
$document->setBody($movie);
$document->index();
// or $document->create();
// or $document->update();
// OR
$document = new \Acme\Search\MovieDocument();
$document->setBody($movie);
$document->setTransformer('Acme\MovieTransformer');
$document->index();
$document = new \Acme\Search\MovieDocument();
$document->delete($movie->id);