Browse Source

产生es用的分词数据

master
Mike 5 years ago
parent
commit
92118af7df
  1. 5
      .gitignore
  2. 54
      app/Console/Commands/GenEsDicts.php
  3. 11
      app/Models/EsDict.php

5
.gitignore

@ -14,4 +14,7 @@ yarn-error.log
.idea
.vscode/launch.json
/storage/debugbar
/public/certs
/public/certs
/public/es_dicts.txt
/public/es_use_dicts.txt
/public/es_unuse_dicts.txt

54
app/Console/Commands/GenEsDicts.php

@ -0,0 +1,54 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\EsDict;
class GenEsDicts extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:GenEsDicts';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command 生成Es分词数据';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$es = EsDict::whereNull('deleted_at')->pluck('title')->toArray();
//dd($es);
$es = implode("\n",$es);
$file_path = public_path() . '/es_use_dicts.txt';
file_put_contents($file_path,$es);
$es = EsDict::whereNotNull('deleted_at')->pluck('title')->toArray();
$es = implode("\n",$es);
$file_path = public_path() . '/es_unuse_dicts.txt';
file_put_contents($file_path,$es);
return 0;
}
}

11
app/Models/EsDict.php

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class EsDict extends Model
{
protected $table = 'lanzu_es_dicts';
protected $dateFormat = 'U';
}
Loading…
Cancel
Save