2019-09-12 11:08:25 +02:00
|
|
|
<?php
|
2022-04-19 16:07:27 +02:00
|
|
|
|
2022-06-20 14:57:58 +02:00
|
|
|
namespace App\Traits\Models;
|
2019-09-12 11:08:25 +02:00
|
|
|
|
2022-04-19 16:07:27 +02:00
|
|
|
use Elasticquent\ElasticquentTrait;
|
2019-09-12 11:08:25 +02:00
|
|
|
|
2022-06-20 14:57:58 +02:00
|
|
|
/**
|
|
|
|
|
* @mixin \Elasticquent\ElasticquentTrait
|
|
|
|
|
*/
|
|
|
|
|
trait BindedToElasticSearch
|
2022-04-19 16:07:27 +02:00
|
|
|
{
|
2019-09-12 11:08:25 +02:00
|
|
|
use ElasticquentTrait;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Index Exists.
|
|
|
|
|
*
|
|
|
|
|
* Does this index exist?
|
|
|
|
|
*
|
2022-04-19 16:07:27 +02:00
|
|
|
* @return boolean
|
2019-09-12 11:08:25 +02:00
|
|
|
*/
|
|
|
|
|
public static function indexExists()
|
|
|
|
|
{
|
2022-04-19 16:07:27 +02:00
|
|
|
$instance = new static();
|
|
|
|
|
$client = $instance->getElasticSearchClient();
|
|
|
|
|
$index = array(
|
2019-09-12 11:08:25 +02:00
|
|
|
'index' => $instance->getIndexName(),
|
|
|
|
|
);
|
|
|
|
|
return $client->indices()->exists($index);
|
|
|
|
|
}
|
|
|
|
|
}
|