abetzi / elasticsearch-migrate
该包最新版本(dev-main)没有可用的许可证信息。
dev-main
2023-06-15 10:19 UTC
Requires
- elasticsearch/elasticsearch: ^8.2
- laravel/framework: ^9.11
- laravel/scout: ^10.0
Requires (Dev)
- php-http/mock-client: ^1.5
- phpunit/phpunit: ^9.5.10
This package is not auto-updated.
Last update: 2024-09-18 16:56:53 UTC
README
为 Laravel 框架提供简单的 elasticsearch 索引操作。
基本用法
artisan es:index:info Show info on given index and its related aliases
artisan es:template:create Create elasticsearch template from given yaml file
artisan scout:delete-all-indexes Delete all indexes
artisan scout:delete-index Delete an index
artisan scout:flush Flush all of the models records from the index
artisan scout:import Import the given model into the search index
artisan scout:index Create an index
artisan about Info about elasticsearch connection
SCOUT_DRIVER=elasticsearch
ELASTICSEARCH_HOST=localhost:9200
ELASTICSEARCH_USERNAME=elastic
ELASTICSEARCH_PASSWORD=elastic
ELASTICSEARCH_SSL_VERIFICATION=false
安装 - 作为开发目的的 git 子模块
首先 - 下载源文件
git submodule add git@bitbucket.org:puntik/elasticsearch-migrate.git
安装所需库
composer install elasticsearch/elasticsearch
composer install laravel/scout
然后,将提供者注入到 config/app.php 中
<?php
[
'providers' => [
// ...
/*
* Package Service Providers...
*/
Abetzi\Elasticsearch\Providers\ElasticsearchProvider::class,
],
]
别忘了在 composer.json 中添加 autoload psr-4 映射。
{
"autoload": {
"psr-4": {
"Abetzi\\Elasticsearch\\": "src/elasticsearch-migrate/src/"
}
}
}
配置 config/services.php
<?php
return [
// ...
'elasticsearch' => [
'hosts' => explode(',', env('ELASTICSEARCH_HOST', 'https://host.docker.internal:9210')),
'username' => env('ELASTICSEARCH_USERNAME', 'elastic'),
'password' => env('ELASTICSEARCH_PASSWORD', 'elastic'),
'ssl_verification' => env('ELASTICSEARCH_SSL_VERIFICATION', true)
],
];
安装 - composer
尚未完成。
- composer install ...
- 配置 .env
- artisan publish ...
- 应该可以工作
用例 - 索引管理
- [x] 想创建一个名为 {alias_name}-000001 的新索引,别名不存在
- [x] 想创建一个名为 {alias_name}-000001 的新索引,删除旧别名并设置新别名
- [x] 想加载 yaml 模板并将其保存到索引中
- [ ] 想删除与别名 {alias_name} 关联的索引
- [ ] 想删除所有与模式 {alias_name}-000001 匹配的索引,这些索引不指向别名 {alias_name}
- [ ] 想列出所有与模式 {name} 匹配的索引和别名信息
待办事项
- [x] 重构
- [ ] 参数化
- [x] 分解到服务
- [x] 创建提供者
- [x] 创建命令
- [ ] 编写说明
- [ ] 发布到 packages - 准备 composer.json
- [ ] 编写关于客户端配置的文档
- [ ] 实现 scout:create-index 而不是我的类
- [ ] 实现 scout:delete-index 而不是我的类