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

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

发布了77 篇原创文章 · 获赞 33 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_39337886/article/details/103785805