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);