2
0

IndexOpenSearch.php 964 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use App\Services\OpenSearchService;
  5. use Illuminate\Support\Facades\App;
  6. class IndexOpenSearch extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'app:index-open-search';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = '如果是新的索引 全量更新openSearch';
  20. /**
  21. * Execute the console command.
  22. */
  23. public function handle()
  24. {
  25. //
  26. $service = app(OpenSearchService::class);
  27. if ($service->count() === 0) {
  28. $this->call('opensearch:index-tipitaka', ['book' => 0, '--granularity' => 'all']);
  29. $this->call('opensearch:index-term');
  30. } else {
  31. if (App::environment('local')) {
  32. $this->info('data exist');
  33. }
  34. }
  35. }
  36. }