1. Go to this page and download the library: Download vikram/es 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/ */
vikram / es example snippets
use Fadion\Bouncy\BouncyTrait;
class Product extends Eloquent {
use BouncyTrait;
// ...other Eloquent attributes
// or methods.
}
$products = App\Product::search($params);
$products->total(); // Total number of hits
$products->maxScore(); // Maximum score of the results
$products->took(); // Time in ms it took to run the query
$products->timedOut(); // Wheather the query timed out, or not.
$products->shards(); // Array of shards information
$products->shards($key); // Information on specific shard
$products = App\Product::search($params);
foreach ($products as $product) {
$product->isDocument(); // Checks if it's an Elasticsearch document
$product->documentScore(); // Score set in search results
$product->documentVersion(); // Document version if present
}
$params = [
'query' => [
'match_all' => new \stdClass()
]
];
// how long between scroll requests. should be small!
$scrollTime = "30s";
// how many results *per shard* you want back
$size = 10000;
$products = App\Product::scroll($params, $scrollTime, $size);
$mappingProperties = [
'name' => [
'type' => 'completion'
]
];
$searchText = 'a'; // example
$params = [
'suggest' => [
'name-suggest' => [
'prefix' => $searchText,
'completion' => [
'field' => 'name',
'size' => 10,
]
]
]
];
$productsCollection = App\Product::suggest($params);
// To get the products from the code
$products = $productsCollection['suggest']['name-suggest'][0]['options'];
use Illuminate\Database\Eloquent\Collection;
use Fadion\Bouncy\BouncyCollectionTrait;
class MyAwesomeCollection extends Collection {
use BouncyCollectionTrait;
}
Elastic::index();
Elastic::get();
Elastic::search();
Elastic::indices()->create();
// and any other method it provides
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.