elasticsearch服务(192.168.24.188)
测试机(192.168.24.187)(避免权限)
cd ~
vim test/composer.json
composer install
{
"require": {
"elasticsearch/elasticsearch": "~6.0"
}
}
mv 项目目录
chown -R www:www 赋权
-----------------------------------------------------------------------------------------------------------------------------------
测试
添加index.php
<?php
require 'vendor/autoload.php';
use Elasticsearch\ClientBuilder;
$client = ClientBuilder::create()->setHosts(["192.168.24.188:9200"])->build();
//索引一个文档
$params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id',
'body' => ['testField' => 'abc']
];
$response = $client->index($params);
print_r($response);