xdm / elastic
Encapsulating ES query statements
v0.2
2017-09-14 08:29 UTC
Requires
- php: >=5.6
- elasticsearch/elasticsearch: ~5.0
- ongr/elasticsearch-dsl: ^5.0
This package is not auto-updated.
Last update: 2024-03-17 01:09:45 UTC
README
- 1、composer require "xdm/elastic"
- 2、调用方法:
use Xdm\Elastic\Elastic;
//construct set host
$elastic = new Elastic($host);
//set index
$elastic->index($index);
//set type
$elastic->type($type);
//add where conditon filter
$elastic->where(['key' => 'value']);
//add whereIn conditon filter
$elastic->whereIn('key', ['value1', 'value2']);
//add range condition filter
$elastic->range('key', ['gte' => 'value1', 'lte' => 'value2']);
//set size
$elastic->take(100);
//add Aggregation
$elastic->count($field);
$elastic->groupBy($field);
$elastic->sum($field);
$elastic->max($field);
$elastic->min($field);
$elastic->avg($field);
//set order
$elastic->orderBy($field, 'desc');
//send query and get response
$response = $elastic->search();