wupengfei 2 years ago
parent
commit
5933524055
3 changed files with 10 additions and 2 deletions
  1. 2 1
      .idea/workspace.xml
  2. 7 0
      application/common.php
  3. 1 1
      application/common/service/Elasticsearch.php

+ 2 - 1
.idea/workspace.xml

@@ -3,6 +3,7 @@
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/common.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/application/common/service/Elasticsearch.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common/service/Elasticsearch.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
@@ -256,7 +257,7 @@
       <workItem from="1678322422199" duration="23277000" />
       <workItem from="1678410737283" duration="21226000" />
       <workItem from="1678495559564" duration="25187000" />
-      <workItem from="1678668116151" duration="3575000" />
+      <workItem from="1678668116151" duration="3782000" />
     </task>
     <servers />
   </component>

+ 7 - 0
application/common.php

@@ -1,5 +1,12 @@
 <?php
 use think\Db;
+use Elastic\Elasticsearch\ClientBuilder;
+function es()
+{
+    static $es;
+    if(!$es) $es= ClientBuilder::create()->build();
+    return $es;
+}
 /**
  * 秒转换为天
  */

+ 1 - 1
application/common/service/Elasticsearch.php

@@ -39,7 +39,7 @@ class Elasticsearch
 
     public static function getList($index)
     {
-       $list =  static::es()->search([
+       $list = es()->search([
             'index'=>$index,
         ]);
        return $list;