PHPackages                             rulerz-php/elasticsearch - 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. [API Development](/categories/api)
4. /
5. rulerz-php/elasticsearch

ActiveLibrary[API Development](/categories/api)

rulerz-php/elasticsearch
========================

Elasticsearch compilation target for RulerZ

13141PHPCI failing

Since Jan 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/rulerz-php/elasticsearch)[ Packagist](https://packagist.org/packages/rulerz-php/elasticsearch)[ RSS](/packages/rulerz-php-elasticsearch/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Elasticsearch compilation target for RulerZ [![Build Status](https://camo.githubusercontent.com/57d077bedcb4b021db9a53cd0d47f7a3041c6b537c00f0d79590ed404a4f53e4/68747470733a2f2f7472617669732d63692e6f72672f72756c65727a2d7068702f656c61737469637365617263682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rulerz-php/elasticsearch)
===================================================================================================================================================================================================================================================================================================================================================

[](#elasticsearch-compilation-target-for-rulerz-)

Elasticsearch compilation target for [RulerZ](https://github.com/K-Phoen/rulerz).

Usage
-----

[](#usage)

[elastic/elasticsearch-php](https://github.com/elastic/elasticsearch-php) is one of the targets supported by RulerZ. It allows the engine to query an Elasticsearch server.

This cookbook will show you how to retrieve objects using the official client for Elasticsearch and RulerZ.

Here is a summary of what you will have to do:

- [configure elastic/elasticsearch-php](#configure-elasticelasticsearch-php);
- [configure RulerZ](#configure-rulerz);
- [filter your target](#filter-your-target).

Configure elastic/elasticsearch-php
-----------------------------------

[](#configure-elasticelasticsearch-php)

This subject won't be directly treated here. You can either follow the [official documentation](http://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_installation_2.html)or use a bundle/module/whatever the framework you're using promotes.

### Configure RulerZ

[](#configure-rulerz)

Once elastic/elasticelasticsearch-php is installed and configured we can the RulerZ engine:

```
$rulerz = new RulerZ(
    $compiler, [
        new \RulerZ\Elasticsearch\Target\Elasticsearch(), // this line is Elasticsearch-specific
        // other compilation targets...
    ]
);
```

The only Elasticsearch-related configuration is the `Elasticsearch` target being added to the list of the known compilation targets.

### Filter your target

[](#filter-your-target)

Now that both elastic/elasticsearch-php and RulerZ are ready, you can use them to retrieve data.

The `Elasticsearch` instance that we previously injected into the RulerZ engine only knows how to use `Elasticsearch\Client` objects so the first step is creating one:

```
$client = new Elasticsearch\Client();
```

And as usual, we call RulerZ with our target (the `Search` object) and our rule. RulerZ will build the right executor for the given target and use it to filter the data, or in our case to retrieve data from Elasticsearch.

```
$rule  = 'gender = :gender and points > :points';
$parameters = [
    'points' => 30,
    'gender' => 'M',
];
$executionContext = [
    'index' => 'index_name',
    'type'  => 'type_name',
];

var_dump(
    iterator_to_array($rulerz->filter($client, $rule, $parameters, $executionContext))
);
```

**N.B**: you'll notice an unusual variable named `$executionContext`. It contains a few parameters needed by the `Elasticsearch` in order to make the request and are mandatory.

That's it!

License
-------

[](#license)

This library is under the [MIT](LICENSE) license.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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://avatars.githubusercontent.com/u/66958?v=4)[Kévin Gomez](/maintainers/K-Phoen)[@K-Phoen](https://github.com/K-Phoen)

---

Top Contributors

[![K-Phoen](https://avatars.githubusercontent.com/u/66958?v=4)](https://github.com/K-Phoen "K-Phoen (18 commits)")

### Embed Badge

![Health badge](/badges/rulerz-php-elasticsearch/health.svg)

```
[![Health](https://phpackages.com/badges/rulerz-php-elasticsearch/health.svg)](https://phpackages.com/packages/rulerz-php-elasticsearch)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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