3.elasticsearch-head

git地址

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

在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章