123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- <?php
- /**
- * ElasticSearch 初始化脚本
- * Created by PhpStorm.
- * User: phperstar
- * Date: 2019/2/23
- * Time: 2:04 PM
- */
- namespace Jobs\Controller;
- use Mall\Framework\Factory;
- use Mall\Framework\Core\Request;
- class CESinit
- {
- /**
- * Search Demo
- */
- public function search()
- {
- $data = Request::params();
- $c = $data['b'] ?: 1;
- switch ($c) {
- // 添加wms日志索引库
- case 1 :
- $mappings = array(
- 'mappings' => array(
- "_default_" => [
- "properties" => [
- 'userId' => ['type' => 'integer'],
- "userName" => [
- "type" => "text",
- "store" => false,
- "analyzer" => "ik_max_word",
- "search_analyzer" => "ik_max_word",
- "boost" => 10
- ],
- 'object' => ['type' => 'keyword'],
- 'actionType' => ['type' => 'keyword'],
- "logContent" => [
- "type" => "text",
- "store" => false,
- "analyzer" => "ik_max_word",
- "search_analyzer" => "ik_max_word",
- "boost" => 5
- ],
- 'time' => ['type' => 'integer'],
- ]
- ]
- )
- );
- $searchServer = Factory::search('wms');
- $result = $searchServer->createBase('dev_wms_operation_log', $mappings);
- if ($result && !isset($result['error'])) {
- echo 'dev_wms_operation_log init done.';
- return true;
- } else {
- print_r($result['error']);
- return false;
- }
- break;
- // 删除wms索引库
- case 2:
- $searchServer = Factory::search('wms');
- $searchServer->setIndex('dev_wms_operation_log');
- $a = $searchServer->deleteBase('dev_wms_operation_log');
- print_r($a);
- break;
- // 添加oms订单状态日志索引库
- case 3 :
- $mappings = array(
- 'mappings' => array(
- "_default_" => [
- "properties" => [
- 'orderNo' => ['type' => 'keyword'],
- 'status' => ['type' => 'integer'],
- 'operationUserName' => ['type' => 'keyword'],
- 'time' => ['type' => 'integer'],
- ]
- ]
- )
- );
- $searchServer = Factory::search('wms');
- $result = $searchServer->createBase('dev_oms_orderstatus_log', $mappings);
- if ($result && !isset($result['error'])) {
- echo 'dev_oms_orderstatus_log init done.';
- return true;
- } else {
- print_r($result['error']);
- return false;
- }
- break;
- // 删除oms订单状态索引库
- case 4:
- $searchServer = Factory::search('wms');
- $searchServer->setIndex('dev_oms_orderstatus_log');
- $a = $searchServer->deleteBase('dev_oms_orderstatus_log');
- print_r($a);
- break;
- // 添加capital日志索引库
- case 5 :
- $mappings = array(
- 'mappings' => array(
- "_default_" => [
- "properties" => [
- 'userId' => ['type' => 'integer'],
- "userName" => [
- "type" => "text",
- ],
- 'object' => ['type' => 'keyword'],
- 'actionType' => ['type' => 'keyword'],
- "logContent" => [
- "type" => "text",
- "store" => false,
- "analyzer" => "ik_max_word",
- "search_analyzer" => "ik_max_word",
- "boost" => 5
- ],
- 'time' => ['type' => 'integer'],
- ]
- ]
- )
- );
- $searchServer = Factory::search('capital');
- $result = $searchServer->createBase('dev_capital_operation_log', $mappings);
- if ($result && !isset($result['error'])) {
- echo 'dev_capital_operation_log init done.';
- return true;
- } else {
- print_r($result['error']);
- return false;
- }
- break;
- // 删除wms索引库
- case 6:
- $searchServer = Factory::search('capital');
- $searchServer->setIndex('dev_capital_operation_log');
- $a = $searchServer->deleteBase('dev_capital_operation_log');
- print_r($a);
- break;
- // 添加oms日志索引库
- case 7 :
- $mappings = array(
- 'mappings' => array(
- "_default_" => [
- "properties" => [
- 'userId' => ['type' => 'integer'],
- "userName" => [
- "type" => "text",
- ],
- 'object' => ['type' => 'keyword'],
- 'actionType' => ['type' => 'keyword'],
- "logContent" => [
- "type" => "text",
- "store" => false,
- "analyzer" => "ik_max_word",
- "search_analyzer" => "ik_max_word",
- "boost" => 5
- ],
- 'time' => ['type' => 'integer'],
- ]
- ]
- )
- );
- $searchServer = Factory::search('oms');
- $result = $searchServer->createBase('dev_oms_operation_log', $mappings);
- if ($result && !isset($result['error'])) {
- echo 'dev_oms_operation_log init done.';
- return true;
- } else {
- print_r($result['error']);
- return false;
- }
- break;
- // 删除wms索引库
- case 8:
- $searchServer = Factory::search('oms');
- $searchServer->setIndex('dev_oms_operation_log');
- $a = $searchServer->deleteBase('dev_oms_operation_log');
- print_r($a);
- break;
- }
- }
- }
|