PHPackages                             iivannov/elastic-commander - 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. iivannov/elastic-commander

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

iivannov/elastic-commander
==========================

Wrapper for the official Elasticsearch PHP Client

6.7.2(4y ago)4613MITPHPPHP &gt;=7.1

Since Oct 7Pushed 4y ago2 watchersCompare

[ Source](https://github.com/iivannov/elastic-commander)[ Packagist](https://packagist.org/packages/iivannov/elastic-commander)[ RSS](/packages/iivannov-elastic-commander/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (1)Versions (6)Used By (0)

Elastic Commander
=================

[](#elastic-commander)

This a simple and easy to use wrapper for the official low-level Elasticsearch PHP Client.

It simplifies the work with Elasticsearch API by offering a lot of helper methods for managing indices, adding and updating documents and searching the index.

---

Installation
============

[](#installation)

Via Composer

```
$composer require iivannov/elastic-commander

```

---

Usage
=====

[](#usage)

Initialization
--------------

[](#initialization)

Minimum required (will work with default host - localhost:9200)

```
$commander = new Commander('YourIndexName');

```

With a list of hosts

```
$hosts = [
    '192.168.1.1:9200',         // IP + Port
    '192.168.1.2',              // Just IP
    'mydomain.server.com:9201', // Domain + Port
    'mydomain2.server.com',     // Just Domain
    'https://localhost',        // SSL to localhost
    'https://192.168.1.3:9200'  // SSL to IP + Port
];

$commander = new Commander('YourIndexName', $hosts);

```

With a custom handler

```
$handler = new MyCustomHandler();
$commander = new Commander('YourIndexName', $hosts, $handler);

```

N.B. Each instance of the Commander works with the index name specified when initializing it. All actions and queries will be executed on this index. If you want to set a new index name to work with use:

```
$commander->reset('NewIndexName');

```

Index
-----

[](#index)

### 1. Create the index

[](#1-create-the-index)

```
$commander->index()->create();

```

### 2. Delete the index

[](#2-delete-the-index)

```
$commander->index()->delete();

```

### 3. Reset the index

[](#3-reset-the-index)

A helper method that will reset the index by deleting it and creating it again.

```
$commander->index()->reset();

```

### 4. Optimize the index

[](#4-optimize-the-index)

// Not finished

```
$commander->index()->optimize();

```

### 5. Statistics about the index

[](#5-statistics-about-the-index)

// Not finished

```
$commander->index()->stats();

```

---

Mapping
-------

[](#mapping)

### 1. Put Mapping

[](#1-put-mapping)

```
$commander->mapping($mapping);

```

---

Document
--------

[](#document)

### 1. Check if document exists by id

[](#1-check-if-document-exists-by-id)

```
$commander->document('SomeDocumentType')->exists($id);

```

### 2. Get document by id

[](#2-get-document-by-id)

```
$commander->document('SomeDocumentType')->get($id);

```

### 3. Add document

[](#3-add-document)

In current version the add method expects an ID for the document.

```
$commander->document('SomeDocumentType')->add($id, $parameters);

```

### 4. Update document

[](#4-update-document)

```
$commander->document('SomeDocumentType')->add($id, $parameters);

```

---

Search
------

[](#search)

Searching is done by passing a raw query array or by using a custom criteria class. After the query you have the option to get: the full response, only the ids, a map of the results or the total count.

### 1. Raw Query

[](#1-raw-query)

```
$result = $commander->search('SomeDocumentType')->query($query, $sort, $size, $from);

```

### 2. Criteria Query

[](#2-criteria-query)

```
$result = $commander->search('SomeDocumentType')->criteria($criteria);

```

Result
------

[](#result)

After running either a raw query or one with a criteria class you can use one of the helper methods for manipulating the result response.

### 1. Return ElasticSearch raw response

[](#1-return-elasticsearch-raw-response)

```
$result->response();

```

### 2. Return total number of results

[](#2-return-total-number-of-results)

```
$result->total();

```

### 3. Return an array of IDs for the found hits

[](#3-return-an-array-of-ids-for-the-found-hits)

```
$result->ids();

```

### 3. Return an array of objects for the found hits

[](#3-return-an-array-of-objects-for-the-found-hits)

The key will be the \_id of the hit and the value will be an stdClass of the \_source

```
$result->hits();

```

---

Count
-----

[](#count)

// Not finished

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 77.8% 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 ~495 days

Total

5

Last Release

1574d ago

Major Versions

1.0.2 → 2.0.02019-03-26

2.0.0 → 6.7.02019-07-16

PHP version history (3 changes)1.0.1PHP &gt;=5.4.0

6.7.0PHP ^7.1

6.7.2PHP &gt;=7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7932620?v=4)[Ivan Ivanov](/maintainers/iivannov)[@iivannov](https://github.com/iivannov)

---

Top Contributors

[![iivannov](https://avatars.githubusercontent.com/u/7932620?v=4)](https://github.com/iivannov "iivannov (7 commits)")[![budhead](https://avatars.githubusercontent.com/u/2962473?v=4)](https://github.com/budhead "budhead (1 commits)")[![dimitar-ilkov-sumup](https://avatars.githubusercontent.com/u/39384124?v=4)](https://github.com/dimitar-ilkov-sumup "dimitar-ilkov-sumup (1 commits)")

---

Tags

phpclientelasticsearchelastic

### Embed Badge

![Health badge](/badges/iivannov-elastic-commander/health.svg)

```
[![Health](https://phpackages.com/badges/iivannov-elastic-commander/health.svg)](https://phpackages.com/packages/iivannov-elastic-commander)
```

###  Alternatives

[elasticsearch/elasticsearch

PHP Client for Elasticsearch

5.3k184.2M1.1k](/packages/elasticsearch-elasticsearch)[babenkoivan/elastic-client

The official PHP Elasticsearch client integrated with Laravel

544.3M6](/packages/babenkoivan-elastic-client)[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

935572.3k2](/packages/mailerlite-laravel-elasticsearch)[babenkoivan/elastic-adapter

Adapter for official PHP Elasticsearch client

404.3M9](/packages/babenkoivan-elastic-adapter)[babenkoivan/elastic-scout-driver

Elasticsearch driver for Laravel Scout

2774.0M6](/packages/babenkoivan-elastic-scout-driver)[babenkoivan/elastic-scout-driver-plus

Extension for Elastic Scout Driver

2873.0M2](/packages/babenkoivan-elastic-scout-driver-plus)

PHPackages © 2026

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