PHPackages                             onming/es-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. onming/es-php-sdk

ActiveLibrary[Search &amp; Filtering](/categories/search)

onming/es-php-sdk
=================

es-php-sdk

2.0.0(4y ago)029MITPHPPHP &gt;=7.0

Since Mar 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/onming/es-php-sdk)[ Packagist](https://packagist.org/packages/onming/es-php-sdk)[ RSS](/packages/onming-es-php-sdk/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

es-php-sdk
==========

[](#es-php-sdk)

elasticsearch sdk插件 将会陆续更新

环境准备
----

[](#环境准备)

- PHP 7.0+ 您可以通过`php -v`命令查看当前的 PHP 版本。
- curl 扩展 您可以通过`php -m`命令查看 curl 扩展是否已经安装好。
- 安装ELK 7.0+ 安装文档

安装方式
----

[](#安装方式)

### Composer 方式

[](#composer-方式)

```
composer require onming/es-php-sdk ~2.0

```

### 使用方法

[](#使用方法)

```
use Onming\EsPhpSdk\Client;

$hosts = [
    'host' => '127.0.0.1',
    'port' => '9200',
    'scheme' => 'http',
    'user' => '',
    'pass' => '',
];
$client = new Client($hosts);
// 测试Analyze
$result = $client->getAnalyze('测试中文分词');
var_dump($result);
// 删除索引
$result = $client->deleteIndex('test_index');
var_dump($result);
// 创建索引
// +----------------------------------------------------------------------
// | 类型参考
// | text:全文检索，分词
// | keyword:精确查询不分词
// | Intger:整形
// | float:浮点
// | nested:存储array或json
// | date:日期类型 格式化 yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis
// | geo_point:用来存储经纬度
// | ip:可以存储IPV4 和IPV6
// +----------------------------------------------------------------------
$properties = [
    'md5' => [
        'type' => 'keyword',
    ],
    'tag' => [
        'type' => 'text',
        'analyzer' => 'ik_max_word',
        'index' => true,
        'store' => false,
    ],
    'scale' => [
        'type' => 'float',
    ],
    'position' => [
        'type' => 'geo_point',
    ],
    'caeate_at' => [
        'type' => 'date',
        'format' => 'yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis',
    ],
];
$result = $client->createIndex('test_index', $properties);
var_dump($result);
// 添加文档
$body = [
    'md5' => '111111',
    'tag' => '狗,宠物,动物,户外,狗狗,哺乳动物,毛茸茸,雪,可爱,自然',
    'scale' => 1.1,
    'position' => ['lon' => 116.111, 'lat' => 39.111],
    'create_at' => date('Y-m-d H:i:s'),
];
$result = $client->insert('test_index', '1', $body);
var_dump($result);
$body = [
    'md5' => '222222',
    'tag' => '老虎,宠物,动物,户外,狗狗,哺乳动物,毛茸茸,雪,可爱,自然',
    'scale' => 0.8,
    'position' => ['lon' => 116.222, 'lat' => 39.222],
    'create_at' => date('Y-m-d H:i:s'),
];
$result = $client->insert('test_index', '2', $body);
var_dump($result);
// 删除文档
$result = $client->delete('test_index', '1');
var_dump($result);
// 查询所有
$result = $client->search('test_index', 'all');
// 按条件查询排序
$match = ['tag' => '宠物狗'];
$sort = ['_score' => 'desc'];
$result = $client->search('test_index', $match, 0, 100, $sort);
var_dump($result);

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~340 days

Total

2

Last Release

1545d ago

Major Versions

1.0.1 → 2.0.02022-02-23

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/96562525?v=4)[xuemingzhang](/maintainers/xuemingzhang)[@xuemingzhang](https://github.com/xuemingzhang)

---

Top Contributors

[![onming](https://avatars.githubusercontent.com/u/3692010?v=4)](https://github.com/onming "onming (8 commits)")

---

Tags

phpelasticsearches-php-sdk

### Embed Badge

![Health badge](/badges/onming-es-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/onming-es-php-sdk/health.svg)](https://phpackages.com/packages/onming-es-php-sdk)
```

###  Alternatives

[babenkoivan/elastic-migrations

Elasticsearch migrations for Laravel

1962.5M6](/packages/babenkoivan-elastic-migrations)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
