1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace app\common\service;
- use app\service\EsMobileService;
- use Elastic\Elasticsearch\ClientBuilder;
- /**
- * Elasticsearch
- * Class Elasticsearch
- */
- class Elasticsearch
- {
- /**
- * @return \Elastic\Elasticsearch\Client
- * @throws \Elastic\Elasticsearch\Exception\AuthenticationException
- */
- public static function es()
- {
- static $es;
- if(!$es) $es= ClientBuilder::create()->build();
- return $es;
- }
- /*
- *
- */
- public static function body()
- {
- return [
- 'mappings'=>[
- 'properties'=>[
- 'id'=>['type'=>'long'],
- 'status'=>['type'=>'byte'],
- 'logo'=>['type'=>'text'],
- 'name'=>['type'=>'text'],
- ]
- ]
- ];
- }
- public static function getList($index)
- {
- $list = static::es()->search([
- 'index'=>$index,
- ]);
- return $list;
- }
- }
|