前提・実現したいこと
現在Fuel PHPで作成中のWebサービス内にてAWS Elasticsearchを利用して検索システムを強化したいと思っております。
ElasticsearchのライブラリであるElasticaを使用してIAM roll認証を設定するところまでは良いのですが、
indexの作成方法がわかりません。
発生している問題・エラーメッセージ
Elasticaでデータ投入する処理がわからない。
該当のソースコード
PHP
1<?php 2 3use Elastica\Client; 4use Elastica\Bulk; 5use Elastica\Query; 6use Elastica\Query\MatchAll; 7use Elastica\Query\Term; 8use Elastica\Query\QueryString; 9use Elastica\Query\Bool; 10use Elastica\Query\Range; 11use Elastica\Query\MoreLikeThis; 12 13class AWSElasticsearch 14{ 15 public function search($type, $id, $key, $value) 16 { 17 $client = new Elastica\Client([ 18 'host' => 'https://xxxxxx.ap-northeast-1.es.amazonaws.com', 19 'port' => 443, 20 'transport' => ['type' => 'AwsAuthV4', 'postWithRequestBody' => true], 21 'aws_region' => 'ap-northeast-1', 22 ]); 23 24 $params = [ 25 'index' => '*', 26 'type' => $type, 27 'id' => $id, 28 'body' => [$key => $value] 29 ]; 30 31 $response = $client->search($params); 32 var_dump($response);exit; 33 } 34 35 public function insert() 36 { 37 $client = new Client([ 38 'host' => 'https://xxxxxx.ap-northeast-1.es.amazonaws.com', 39 'port' => 443, 40 'transport' => ['type' => 'AwsAuthV4', 'postWithRequestBody' => true], 41 'aws_region' => 'ap-northeast-1', 42 ]); 43 44 $params = [ 45 'index' => 'test_index', 46 'type' => 'test_type', 47 'id' => '1', 48 'body' => ['name' => 'test_1'] 49 ]; 50 51 $index = $client->getIndex('test_index'); 52 $type = $index->getType('test_type'); 53 54} 55
試したこと
調べたことは一通り試したのですが、そもそも該当する情報が少ないです。。
補足情報(FW/ツールのバージョンなど)
あなたの回答
tips
プレビュー