構文を改善し、次の手順に従います。1) エラー報告をオンに設定します。
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
session_start();
2) 'vendor/autoload.php' が必要です。(composer を使用してインストール)
3) オブジェクトを作成する
$client = new Elasticsearch\Client();
$elasticaClient = new Elastica\Client();
$reque=new Elastica\Request($elasticaClient);
4) プログラム例
$index = $elasticaClient->getIndex('test');
$index->create(array(), true);
$type = $index->getType('test');
$type->addDocument(new Elastica\Document(1, array('username' => 'ruflin')));
$index->refresh();
$query = array(
'query' => array(
'query_string' => array(
'query' => 'ruflin',
)
)
);
//$typee =$reque->GET;
$path = $index->getName() . '/' . $type->getName() . '/_search';
$response = $elasticaClient->request($path, $reque::GET, $query);
$responseArray = $response->getData();
echo "<pre>";
print_r($responseArray);
参照リンク
作曲
b) https://getcomposer.org/doc/01-basic-usage.md
H) https://www.digitalocean.com/community/articles/how-to-install-and-use-composer-on-your -vps-running-ubuntu