PHPackages                             taq/torm-elastic - 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. taq/torm-elastic

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

taq/torm-elastic
================

ElasticSearch integration for TORM

0.1.2(10y ago)2219GPLPHPPHP &gt;=5.3.0

Since Jul 9Pushed 10y ago1 watchersCompare

[ Source](https://github.com/taq/torm-elastic)[ Packagist](https://packagist.org/packages/taq/torm-elastic)[ Docs](http://github.com/taq/torm-elastic)[ RSS](/packages/taq-torm-elastic/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (13)Used By (0)

TORM-elasticsearch
==================

[](#torm-elasticsearch)

This is a trait to insert ElasticSearch funcionality on [TORM](https://github.com/taq/torm) objects.

Installation
------------

[](#installation)

Change (or create, if needed) your Composer file to include it:

```
{
    "require": {
        "taq/torm-elastic": ">=0"
    }
}

```

Usage
-----

[](#usage)

Just open your model and insert the trait, like:

```
class User extends TORM\Model {
    use TORM\ElasticSearch;
}
User::setElasticSearchIndex("myapp");

```

and, after every object saving, it will be send for ElasticSearch indexing, using some rules:

- Need to insert the trait using `use TORM\ElasticSearch` on the model;
- Need to specify the app name using setElasticSearchIndex(). This will be the ElasticSearch index.
- After inserting the trait, a new `afterInitialize` method will be added on the model. If the model already has a `afterInitialize` method, **the `TORM\ElasticSearch` `afterInitialize` method must be called explicity on its end**. This is because of the way PHP traits works.
- If not specified, **all the model attributes** will be indexed. To define just some key attributes, we can use the `setElasticSearchValues()`method, sending an array with the attributes, like: ```
    User::setElasticSearchValues(["name"]);

    ```

    then only the `name` attribute will be indexed.

Searching
---------

[](#searching)

Then we can search using something like:

```
$rtn = ElasticUser::elasticSearch("name", "john");
var_dump($rtn);

```

resulting in something like

```
array(2) {
  'id' =>
  string(1) "1"
  'name' =>
  string(12) "John Doe Jr."
}

```

Importing
---------

[](#importing)

When importing a new data collection, we can use the `import` method, like:

```
User::elasticImport();

```

Getting document count
----------------------

[](#getting-document-count)

```
User:;elasticCount();

```

Updating a document
-------------------

[](#updating-a-document)

We can explicity update a document using:

```
$obj->updateElasticSearch();

```

Deleting a document
-------------------

[](#deleting-a-document)

We can explicity delete a document using:

```
$obj->deleteElasticSearch();

```

Disabling
---------

[](#disabling)

We can disable updating documents using

```
TORM\ElasticSearchConfigs::disabled(true);

```

and enable again sending `false` on the same method.

Testing
-------

[](#testing)

If using a `TORM` test enviroment (defined setting the enviroment var `TORM_ENV`to `test`), the index name will be automatically changed to `_test`.

If we want to avoid updating a document on the test enviroment, we can use

```
TORM\ElasticSearchConfigs::avoidOnTests(true);

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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 ~0 days

Total

12

Last Release

3965d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/273db918d5bd2c20b61a40797df70fdbee387de22e2c1dd75419868048980d30?d=identicon)[taq](/maintainers/taq)

---

Top Contributors

[![taq](https://avatars.githubusercontent.com/u/9789?v=4)](https://github.com/taq "taq (18 commits)")

---

Tags

elasticsearchormphpdatabaseelasticsearchormactiverecord

### Embed Badge

![Health badge](/badges/taq-torm-elastic/health.svg)

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

###  Alternatives

[pdphilip/elasticsearch

An Elasticsearch implementation of Laravel's Eloquent ORM

145360.2k4](/packages/pdphilip-elasticsearch)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[bephp/activerecord

micro activerecord library in PHP(only 400 lines with comments), support chain calls and relations(HAS\_ONE, HAS\_MANY, BELONGS\_TO).

1202.1k2](/packages/bephp-activerecord)[cycle/active-record

Provides a simple way to work with your database using Active Record pattern and Cycle ORM

671.3k3](/packages/cycle-active-record)[andsalves/doctrine-elastic

Elasticsearch Doctrine Adaptation

156.6k](/packages/andsalves-doctrine-elastic)[kumbia/activerecord

Fast ActiveRecord

261.6k](/packages/kumbia-activerecord)

PHPackages © 2026

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