{"id":22678290,"url":"https://github.com/hyperf-ext/elasticsearch","last_synced_at":"2025-04-12T14:41:43.185Z","repository":{"id":56987675,"uuid":"303909713","full_name":"hyperf-ext/elasticsearch","owner":"hyperf-ext","description":"The Hyperf Elasticsearch package.","archived":false,"fork":false,"pushed_at":"2021-07-30T18:49:10.000Z","size":12,"stargazers_count":2,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T09:12:20.962Z","etag":null,"topics":["elasticsearch","hypeerf","php","search","swoole"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperf-ext.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-14T05:14:35.000Z","updated_at":"2024-12-16T06:01:45.000Z","dependencies_parsed_at":"2022-08-21T09:40:28.496Z","dependency_job_id":null,"html_url":"https://github.com/hyperf-ext/elasticsearch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf-ext%2Felasticsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf-ext%2Felasticsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf-ext%2Felasticsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf-ext%2Felasticsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperf-ext","download_url":"https://codeload.github.com/hyperf-ext/elasticsearch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248296038,"owners_count":21080217,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elasticsearch","hypeerf","php","search","swoole"],"created_at":"2024-12-09T18:14:41.423Z","updated_at":"2025-04-12T14:41:43.157Z","avatar_url":"https://github.com/hyperf-ext.png","language":"PHP","readme":"# Hyperf Elasticsearch 组件\n\n该组件为 [Elasticsearch](https://github.com/elastic/elasticsearch-php) 客户端的创建提供了工厂类封装。同时，得益于 [hyperf/guzzle](https://github.com/hyperf/guzzle) 协程组件，该组件为 Elasticsearch 的 `Handler` 实现了协程化，可配置为连接池模式。\n\n## 安装\n\n```shell script\ncomposer require hyperf-ext/elasticsearch\n```\n\n\u003e 如启用 Elasticsearch 客户端日志则需安装 [`hyperf/logger`](https://hyperf.wiki/2.0/#/zh-cn/logger) 组件。\n\n## 发布配置\n\n```shell script\nphp bin/hyperf.php vendor:publish hyperf-ext/elasticsearch\n```\n\n## 配置\n\n```php\n[\n    /*\n    |--------------------------------------------------------------------------\n    | 自定义 Elasticsearch 客户端配置\n    |--------------------------------------------------------------------------\n    |\n    | 详细设置请参阅:\n    | http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_configuration.html\n    */\n\n    'client' =\u003e [\n        'hosts' =\u003e [\n            'http://localhost:9200',\n        ],\n        'retries' =\u003e 1,\n    ],\n\n    /*\n    |--------------------------------------------------------------------------\n    | 连接池设置\n    |--------------------------------------------------------------------------\n    */\n\n    'pool' =\u003e [\n        'enabled' =\u003e true,\n        'min_connections' =\u003e 1,\n        'max_connections' =\u003e 30,\n        'wait_timeout' =\u003e 3.0,\n        'max_idle_time' =\u003e 60.0,\n    ],\n\n    /*\n    |--------------------------------------------------------------------------\n    | Elasticsearch 日志设置\n    |--------------------------------------------------------------------------\n    |\n    | 启用日志需安装 `hyperf/logger` 组件。\n    */\n\n    'logger' =\u003e [\n        'enabled' =\u003e false,\n        'name' =\u003e 'elasticsearch',\n        'group' =\u003e 'default',\n    ],\n];\n```\n\n## 使用\n\n只需简单的注入 `Elasticsearch\\Client` 类即可获取客户端实例对象，所有相关配置都已在 `HyperfExt\\Elasticsearch\\ClientFactory` 工厂类中完成。\n\n```php\n\u003c?php\n\nuse Elasticsearch\\Client;\nuse Hyperf\\Utils\\ApplicationContext;\n\n$client = ApplicationContext::getContainer()-\u003eget(Client::class);\n\n$info = $client-\u003einfo();\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperf-ext%2Felasticsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperf-ext%2Felasticsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperf-ext%2Felasticsearch/lists"}