elasticsearch-php まとめ

www.elastic.co

<?php

use Elasticsearch\ClientBuilder;

// クライアント作成
$elastic = ClientBuilder::create()->setHosts([
    'http://localhost:9200'  // エンドポイント
])->build();

// インデックス取得
$elastic->indices()->get([
    'index' => 'my_index', // インデックス名
]);

// インデックス作成
$elastic->indices()->create([
    'index' => 'my_index',
]);

// インデックス削除
$elastic->indices()->delete([
    'index' => config('scout.elasticsearch.index'),
]);

// インデックスリフレッシュ (削除+作成?要検証)
$elastic->indices()->refresh([
    'index' => config('scout.elasticsearch.index'),
]);