git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
打开链接
http://localhost:9100/
注意点 修改elasticsearch的配置文件yml
http.cors.enabled: true
http.cors.allow-origin: "*" # 允许访问的IP地址段,* 为所有IP都可以访问
使用随机数多创建些数据
<?php
require 'vendor/autoload.php';
use Elasticsearch\ClientBuilder;
// 实例化一个客户端
$client = ClientBuilder::create()->build();
// 索引一个文档(创建一条数据)
$params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id'.rand(1,1000),
'body' => [
'testField' => 'abc'.rand(1,1000),
'name' => '张三'.rand(1,1000),
'age' => rand(10,100),
]
];
$response = $client->index($params);
print_r($response);