PHPackages                             jaeger/e-search - 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. [Database &amp; ORM](/categories/database)
4. /
5. jaeger/e-search

ActiveLibrary[Database &amp; ORM](/categories/database)

jaeger/e-search
===============

Elasticsearch5 PHP Api

5351PHP

Since Dec 9Pushed 9y ago1 watchersCompare

[ Source](https://github.com/jae-jae/e-search)[ Packagist](https://packagist.org/packages/jaeger/e-search)[ RSS](/packages/jaeger-e-search/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

e-search
========

[](#e-search)

Elasticsearch5 PHP Api

---

问：为什么官方已经有了Elasticsearch的PHP包，我还要写一个？ 答：任性

Install
=======

[](#install)

```
composer require jaeger/e-search:dev-master

```

Code Example
============

[](#code-example)

```
$es = new \Jaeger\Es([
    //服务器地址
    'server_url'=>'http://localhost:9200',
    //索引
    'index' => 'news',
    //类型
    'type' => 'article'
]);

//or

$es = (new \Jaeger\Es())->setIndex('news')->setType('article');
```

Mapping 设置映射
------------

[](#mapping-设置映射)

```
$result = $es->setMapping([
   'title' => [
       'type' => 'text',
       'analyzer' => 'ik_smart'
   ],
   'content' => [
          'type' => 'text',
          'analyzer' => 'ik_smart'
      ]
]);
```

Index/Update 索引数据/更新数据
----------------------

[](#indexupdate-索引数据更新数据)

```
$result = $es->index(1,[
    'id' => 1,
    'title' => 'This is title',
    'content' => 'This is content'
]);
```

Delete 删除数据
-----------

[](#delete-删除数据)

```
//delete document for id 1
$result = $es->delete(1);
//delete all documents of  current type
$result = $es->delete();
```

Count 获取当前类型的文档总数量
------------------

[](#count-获取当前类型的文档总数量)

```
$result = $es->count();
//or
$result = $es->request('GET','_count');
```

Id 获取指定ID的文档
------------

[](#id-获取指定id的文档)

```
$result = $es->id(1);
//or
$result = $es->request('GET',1);

```

Search 搜索
---------

[](#search搜索)

```
$result = $es->search($query);

```

`$query` can be an array,JSON string, or string.

### 1.Array

[](#1array)

```
$query = [
    'query' => [
        'match' => [
            'content' => 'this is content'
        ]
    ],
    'highlight' => [
        'fields' => [
            //此处有坑
            'content' => (object)[]
        ]
    ]
];
```

### 2. JSON String

[](#2-json-string)

```
$query = '{
              "query" : {
                  "match" : {
                      "content" : "this is content"
                  }
              },
              "highlight": {
                  "fields" : {
                      "content" : {}
                  }
              }
          }';
```

### 2. String

[](#2-string)

```
$query = 'this is content';
//or
$query = 'content:this is content';
```

Other Command 其它命令
------------------

[](#other-command-其它命令)

```
/**
 * send command 发送命令
 * @param  string           $method  GET,PUT,DELETE,etc
 * @param  string           $command '_search','_count','_mapping',etc
 * @param  array|jsonString $data 　　　send command　with data
 */
$result = $es->request($method,$command,$data);

//example
$result = $this->request('GET','_search',[
    'query' => [
        'match' => [
            'content' => 'this is content'
        ]
    ]
]);
```

Author
======

[](#author)

Jaeger

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/351bb9fcc9e4784597bdeba01667aca7dcf4f56927bb18341d20470fc3295ae6?d=identicon)[jae](/maintainers/jae)

---

Top Contributors

[![jae-jae](https://avatars.githubusercontent.com/u/5620429?v=4)](https://github.com/jae-jae "jae-jae (12 commits)")

### Embed Badge

![Health badge](/badges/jaeger-e-search/health.svg)

```
[![Health](https://phpackages.com/badges/jaeger-e-search/health.svg)](https://phpackages.com/packages/jaeger-e-search)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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