Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pkg6/think-elasticsearch
An easy way to use the official PHP ElasticSearch client in your thinkphp applications.
https://github.com/pkg6/think-elasticsearch
Last synced: 7 days ago
JSON representation
An easy way to use the official PHP ElasticSearch client in your thinkphp applications.
- Host: GitHub
- URL: https://github.com/pkg6/think-elasticsearch
- Owner: pkg6
- License: mit
- Created: 2023-01-07T12:40:24.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-07T12:42:22.000Z (almost 2 years ago)
- Last Synced: 2024-05-16T05:46:30.447Z (6 months ago)
- Language: PHP
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
## 安装
```shell
composer require tp5er/think-elasticsearch
```## 基本配置
```ini
ELASTICSEARCH_HOST=localhost
ELASTICSEARCH_PORT=9200
ELASTICSEARCH_SCHEME=http
ELASTICSEARCH_USER=
ELASTICSEARCH_PASS=
```## 常规使用
> $data = [
> 'body' => [
> 'testField' => 'abc'
> ],
> 'index' => 'my_index',
> 'type' => 'my_type',
> 'id' => 'my_id',
> ];
>
> $client = ClientBuilder::create()->build();
> $return = $client->index($data);您现在可以简单地替换最后两行:
```php
$return = \tp5er\think\elasticsearch\Elasticsearch::index($data);
```这将在默认连接上运行命令。 你可以运行一个命令
任何连接(参见 `defaultConnection` 设置和 `connections` 数组
配置文件)。```php
$return = \tp5er\think\elasticsearch\Elasticsearch::connection('connectionName')->index($data);
```