PHPackages                             aqarmap/elastic-repository - 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. aqarmap/elastic-repository

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

aqarmap/elastic-repository
==========================

elastic search active repository package

1.0.1(8y ago)0121[1 PRs](https://github.com/aqarmap/elastic-repository/pulls)MITPHP

Since Oct 28Pushed 8y ago2 watchersCompare

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

READMEChangelog (1)Dependencies (2)Versions (14)Used By (0)

[![Packagist](https://camo.githubusercontent.com/f71aad00c0703fb6ac16f1bfdd52803e3a696d8597148d1a8354b81aaecf8629/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7573746166616831352f656c61737469632d7265706f7369746f72792e7376673f6c6162656c3d5061636b6167697374267374796c653d666c61742d737175617265)](https://packagist.org/packages/mustafah15/elastic-repository)[![License](https://camo.githubusercontent.com/c7b95faac31bc5361971a9a352adbc7f6b56590cfa0c8ed741156328756482ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d7573746166616831352f656c61737469632d7265706f7369746f72792e7376673f6c6162656c3d4c6963656e7365267374796c653d666c61742d737175617265)](https://github.com/mustafah15/elastic-repository/blob/master/LICENSE)

🎉 Elasticsearch Repository Package
==================================

[](#tada-elasticsearch-repository-package)

Elasticsearch Repository is a simple, smart implementation of Active Repository for Elasticsearch.

🔥 Features
----------

[](#fire-features)

- provide active repository pattern over your elasticsearch indices, types.
- bring query builder into your elasticsearch repositories.
- Minimize lines of code for building elasticsearch queries with system with big business logic.
- Prevent code duplication.
- Reduce potential programming errors.

❕ Installation
--------------

[](#grey_exclamation-installation)

grap it via composer

```
composer require mustafah15/elastic-repository
```

integration
-----------

[](#integration)

**Elasticsearch Repository** package is framework-agnostic and as such can be integrated easily natively or with your favorite framework.

✨ Usage
-------

[](#sparkles-usage)

- Extend ElasticRepository class as a repository for your type or index.

```
class schoolsRepository extends ElasticRepository
{
    // method contains some bussiness logic
    public function returnQueryWherename()
    {
        $this->where('name', 'EGSchool', 0.5)->getResultQuery();
    }
}
```

📋 Documentation
---------------

[](#clipboard-documentation)

`ElasticRepository`
-------------------

[](#elasticrepository)

when you extend `ElasticRepository` class you will have get various functionality

#### `setIndex()`, `setType()`

[](#setindex-settype)

The `setIndex()` and `setType()` methods for setting up your index name and type name into Repository:

#### `setSort()`

[](#setsort)

The `setSort()` method adds main sort criteria for the query: sorting with \_score by default when adding score function

```
// pass field name to sort by
$queryBuilder->setSort('fieldName');
```

#### `setOrder()`

[](#setorder)

The `setOrder()` method to specify sort direction:

```
$queryBuilder->setSort('fieldName')->setOrder('desc');
```

#### `setTransformer($transformer)`

[](#settransformertransformer)

The `setTransformer($transformer)` to add transformer for your result transformer must implement `TransformerContract`

#### `get()`

[](#get)

method `get()` to get result from your final query after building it using query builder:

#### `getResultWithScore()`

[](#getresultwithscore)

The `getResultWithScore($scoreFunction)` method to get results after adding a score function: takes `Query\FunctionScore $functionScore` as a parameter to be applied to your results

#### `getResultQuery()`

[](#getresultquery)

the `getResultQuery()` return Query object

#### `getResultQueryWithScore($scoreFunction)`

[](#getresultquerywithscorescorefunction)

takes `Query\FunctionScore $functionScore` as a parameter to apply scoring to your query

`QueryBuilder`
--------------

[](#querybuilder)

Every ElasticRepository class have it's own query builder which have a lot of operations and functionlity that you can use.

#### `where()`, `whereNot()`

[](#where-wherenot)

The `where()` and `whereNot()` methods adding must and must not to the main filter:

```
//attribute paramter then the expected value and optional value for the field boost
$queryBuilder->where($attribute, $value = null, $boost = 1.0);
```

#### `whereIn()`, `whereNotIn()`

[](#wherein-wherenotin)

The `whereIn()` and `whereNotIn()` methods adding Range to the main filter:

```
//attribute paramter then a optional value for the fields from and to
$queryBuilder->whereIn($attribute, $from = '', $to = '');
```

#### `exist('fieldName')`

[](#existfieldname)

```
$queryBuilder->exist('fieldName');
```

#### `match($attribute, $keyword)`

[](#matchattribute-keyword)

```
$queryBuilder->match('fieldName', $keywordToMatch);
```

---

### TODO

[](#todo)

- caching support

### Contributing

[](#contributing)

Please see [CONTRIBUTING](https://github.com/mustafah15/elastic-repository/blob/master/CONTRIBUTING.md) for details.

### License

[](#license)

The MIT License (MIT). Please see [License](https://github.com/mustafah15/elastic-repository/blob/master/LICENCE) File for more information.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 96.3% 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 ~14 days

Recently: every ~27 days

Total

12

Last Release

3011d ago

Major Versions

0.5.1 → 1.02017-12-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/e1d373ec376a2b086e42080e6ba16a0c08c196040859bdf2769d8b2b2cb50511?d=identicon)[khal3d](/maintainers/khal3d)

---

Top Contributors

[![mustafah15](https://avatars.githubusercontent.com/u/6823250?v=4)](https://github.com/mustafah15 "mustafah15 (78 commits)")[![mohamedhafezqo](https://avatars.githubusercontent.com/u/11503206?v=4)](https://github.com/mohamedhafezqo "mohamedhafezqo (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aqarmap-elastic-repository/health.svg)

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

###  Alternatives

[jolicode/elastically

Opinionated Elastica based framework to bootstrap PHP and Elasticsearch implementations.

2581.8M1](/packages/jolicode-elastically)[getcandy/candy-api

API driven E-commerce solution, written in Laravel

4397.9k1](/packages/getcandy-candy-api)[heyday/silverstripe-elastica

Provides Elastic Search integration for SilverStripe DataObjects using Elastica

1137.9k2](/packages/heyday-silverstripe-elastica)[kunstmaan/search-bundle

The KunstmaanSearchBundle works with ElasticSearch and supports different search providers. The bundle currently supports Elastica as a provider. Add your own objects to index using a tagged service which implements the SearchConfigurationInterface

1886.3k1](/packages/kunstmaan-search-bundle)[t3g/elasticorn

elastic manager based on elastica

155.8k](/packages/t3g-elasticorn)[michaeljennings/laralastica

A laravel package that allows you to search eloquent results using elasticsearch.

102.9k](/packages/michaeljennings-laralastica)

PHPackages © 2026

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