1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\api\controller;
- class Es
- {
- public $access_key = 'LTAI5tJ5p12drZegeWVG33xZ';
- public $access_secret = '82UWAiY5e5wH8tSkRvMtqVoGO0h8SB';
- public $InstanceId = 'es-cn-wwo34hg5t0006xtsj';
- public $test_index = 'product_info';
- public static function client(){
-
- $es = \Elasticsearch\ClientBuilder::create()->build();
- return $es;
- }
- public function es()
- {
- $res = static::client();
- var_dump($res);
- }
- public function createIndex()
- {
- $index = [
- "index"=>"gyx",
- "body"=>[
- "mappings"=>[
- "properties"=>[
- "name"=>[
- "type"=>"keyword"
- ],
- "age"=>[
- "type"=>"byte"
- ],
- "addr"=>[
- "type"=>"text",
- "analyzer"=>"ik_max_word"
- ]
- ]
- ]
- ]
- ];
- $res = static::client()->indices()->create($index);
- var_dump($res);
- }
- }
|