Package Data | |
---|---|
Maintainer Username: | Yongcheng |
Maintainer Contact: | yongcheng.chen@live.com (Yongcheng Chen) |
Package Create Date: | 2016-12-07 |
Package Last Update: | 2024-02-19 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:11:33 |
Package Statistics | |
---|---|
Total Downloads: | 14 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 1 |
Total Forks: | 1 |
Total Open Issues: | 0 |
This is a package to integrate Elasticsearch to Laravel5
It makes you do Elasticsearch just using Eloquent's API.
composer require yong/elasticsuit dev-master
Yong\ElasticSuit\Service\Provider;
'elasticsearch' => [
'hosts'=>['127.0.0.1:9200'],
'ismultihandle'=>0,
'database'=> 'db*',
'prefix' => '',
'settings'=> ['number_of_shards'=>2,'number_of_replicas'=>0]
],
class TestModel extends \Yong\ElasticSuit\Elasticsearch\Model {
protected $connection = 'elasticsearch';
protected $table = 'testmodel';
//relations
public function Childmodel () {
return $this->hasOne(OtherModel::class, '_id');
}
}
$testmodel = new TestModel();
$testmodel->first_name = 'firstname';
$testmodel->last_name = 'lastname';
$testmodel->age = 20;
$testmodel->save();
$collection = TestModel::where('first_name', 'like', 'firstname')
->whereIn('_id', [1,2,3,4,5])
->whereNotIn('_id', [5,6,7,8,9])
->where('_id', '=', 1)
->where('age', '>', 18)
->orWhere('last_name', 'like', 'lastname')
->whereNull('nick_name')
->whereNotNull('age')
->whereMultMatch(['last_name', 'description'], 'search words', '60%')
->skip(10)
->forPage(1, 20)
->take(10)
->limit(10)
->select(['first_name', 'last_name', 'age'])
->get();
* also support sum(), avg(), min(), max(), stats(), count()
* but not for all fields, only numeric fields can use aggregate
//get relations
TestModel::with('childmodel')->where('first_name', 'like', 'firstname')->get();
And of course:
MIT: http://rem.mit-license.org