krisanalfa/ductible
Composer 安装命令:
composer require krisanalfa/ductible
包简介
Laravel and ElasticSearch in harmony.
README 文档
README
Ductible is a Laravel package that deliver a mid-level Elastic Search client.
Installation
You can install ductible via composer cli:
composer install krisanalfa/ductible
Configuration
Register DuctibleServiceProvider to your configuration:
'providers' => [ // ... Zeek\Ductible\DuctibleServiceProvider::class, ],
Optional
Register Facade alias to your configuration:
'aliases' => [ // ... 'Ductible' => Zeek\Ductible\Facades\Ductible::class, ],
Publishing Configuration
By default, you can use Ductible with zero configuration, assuming your Elasticsearch run in http://localhost:9200. If you want something different, you may publish Ductible configuration and make some changes from it:
php artisan vendor:publish --provider="Zeek\Ductible\DuctibleServiceProvider"
Configuration Explained
You can read from inline docs there. It currently supports many aspect of Elasticsearch client configuration, such as:
host(The most common configuration is telling the client about your cluster. read below to know how to configure multiple hosts.).retries(When the client runs out of retries, it will throw the last exception that it received.).log(Where to store your elasticsearch log.).handler(Elasticsearch-PHP uses an interchangeable HTTP transport layer called RingPHP. You may customize your handler here.).pool(The connection pool is an object inside the client that is responsible for maintaining the current list of nodes.).selector(The connection pool manages the connections to your cluster.).serializer(The response serializer.).client.ignores(The library attempts to throw exceptions for common problems. These exceptions match the HTTP response code provided by Elasticsearch.)client.verbose(If you require more information, you can tell the client to return a more verbose response.).
You can set multiple hosts by configuring in your env file like so:
ELASTICSEARCH_HOSTS="localhost:9200|192.168.1.10:9200|http://myserver.com:9200"
Usage
Basic
Ductible provides a low level client interaction, which you can explore as much as you want.
Indexing a Document
$result = Ductible::index([ 'index' => 'myIndex', 'type' => 'myType', 'id' => 1, 'body' => [ 'fieldFoo' => 'Foo', 'fieldBar' => 'Bar', 'fieldBaz' => 'Baz', ], ]);
Getting Document Index
$index = Ductible::get([ 'index' => 'myIndex', 'type' => 'type', 'id' => 1, ]); // The result is an array
Update Document Index
$result = Ductible::index([ 'index' => 'myIndex', 'type' => 'myType', 'id' => 1, 'body' => [ 'fieldFoo' => 'Foo Foo', 'fieldBar' => 'Bar Bar', 'fieldBaz' => 'Baz Baz', ], ]);
Delete Document Index
$index = Ductible::delete([ 'index' => 'myIndex', 'type' => 'type', 'id' => 1, ]); // The result is an array
Searching
$result = Ductible::search($searchParams);
Bulk Indexing Documents
$result = Ductible::bulk($searchParams);
Using Eloquent
To Be Defined
ToDo
- Separate indexing operation based on eloquent model in Ductible main class
- More unit testing
krisanalfa/ductible 适用场景与选型建议
krisanalfa/ductible 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 06 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 krisanalfa/ductible 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 krisanalfa/ductible 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-06-24