PHP code example of nodtem66 / elasticquent

1. Go to this page and download the library: Download nodtem66/elasticquent 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/ */

    

nodtem66 / elasticquent example snippets


    $books = Book::where('id', '<', 200)->get();
    $books->addToIndex();

    $books = Book::search('Moby Dick');
    echo $books->totalHits();

    $books = $books->filter(function ($book) {
        return $book->hasISBN();
    });

use Elasticquent\ElasticquentTrait;

class Book extends Eloquent
{
    use ElasticquentTrait;
}

use Elasticquent\Elasticsearch;

Elasticsearch::indices()->create(['index'=>'default_index']);
sh
php artisan vendor:publish --provider="Cviebrock\LaravelElasticsearch\ServiceProvider"