PHPackages                             nzo/elastic-query-bundle - 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. nzo/elastic-query-bundle

ActiveSymfony-bundle[Search &amp; Filtering](/categories/search)

nzo/elastic-query-bundle
========================

Symfony bundle used to execute search based on simple query language for the Elasticsearch system

v3.1.1(4y ago)2775[1 PRs](https://github.com/nayzo/NzoElasticQueryBundle/pulls)MITPHPPHP &gt;=7.2.5CI failing

Since Apr 18Pushed 4y ago1 watchersCompare

[ Source](https://github.com/nayzo/NzoElasticQueryBundle)[ Packagist](https://packagist.org/packages/nzo/elastic-query-bundle)[ RSS](/packages/nzo-elastic-query-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (32)Used By (0)

NzoElasticQueryBundle
=====================

[](#nzoelasticquerybundle)

[![Build Status](https://camo.githubusercontent.com/7197181f710ee0bb4f2fafda0aa6ba9130d53af511eca78b0d059081353ea738/68747470733a2f2f7472617669732d63692e6f72672f6e61797a6f2f4e7a6f456c6173746963517565727942756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/nayzo/NzoElasticQueryBundle)[![Latest Stable Version](https://camo.githubusercontent.com/04d2ecd3e88728658ad824c05547d6c793e0263b91d90574c42652856a69a39e/68747470733a2f2f706f7365722e707567782e6f72672f6e7a6f2f656c61737469632d71756572792d62756e646c652f762f737461626c65)](https://packagist.org/packages/nzo/elastic-query-bundle)

- Symfony bundle used to execute search based on simple query language for the Elasticsearch system.
- This bundle is based on the FOSElasticaBundle implementation cf:

Versions &amp; Dependencies
---------------------------

[](#versions--dependencies)

NzoElasticQueryBundleElasticsearchSymfonyPHP\[3.0\] (master)7.\*&gt;=4.4^7.2 / ^8.0\[2.0\]5.\* / 6.\*&gt;=4.4^7.2##### Features included:

[](#features-included)

- Search: **match**, **notmatch**, **isnull**, **in**, **notin**, **gte**, **gt**, **lte**, **lt**, **range**, **wildcard**.
- Sort
- Limitation
- Pagination

###### This Bundle is compatible with **Symfony &gt;= 4.4**

[](#this-bundle-is-compatible-with-symfony--44)

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

[](#installation)

Install the bundle:

```
$ composer require nzo/elastic-query-bundle

```

#### Register the bundle in config/bundles.php (without Flex)

[](#register-the-bundle-in-configbundlesphp-without-flex)

```
// config/bundles.php

return [
    // ...
    Nzo\ElasticQueryBundle\ElasticQueryBundle::class => ['all' => true],
];
```

#### Configure the bundle:

[](#configure-the-bundle)

```
# config/packages/nzo_elastic_query.yaml

nzo_elastic_query:
    elastic_index_prefix:  # optional (the index prefix)
    default_page_number:   # optional (default 1)
    limit_per_page:        # optional (default 100)
    items_max_limit:       # optional (default 1000)
    show_score:            # optional (default false)

```

Usage
-----

[](#usage)

```
use Nzo\ElasticQueryBundle\Query\ElasticQuerySearch;

class MyClass
{
    /**
     * @var ElasticQuerySearch
     */
    private $elasticQuerySearch;

    public function __construct(ElasticQuerySearch $elasticQuerySearch)
    {
        $this->elasticQuerySearch = $elasticQuerySearch;
    }

    /**
     * @param string|array $query  (json or array)
     * @param string $entityNamespace The FQCN (fully qualified class name) of the entity to execute the search on.
     * @param null|int $page
     * @param null|int $limit
     * @return array
     */
    public funtion foo($query, $entityNamespace, $page = null, $limit = null)
    {
        // $entityNamespace === 'App\Entity\FooBar'

        return $this->elasticQuerySearch->search($query, $entityNamespace, $page, $limit);

        // check access permission on the search
        return $this->elasticQuerySearch->search(
            $query,
            $entityNamespace,
            $page,
            $limit,
            ['role' => 'ROLE_SEARCH', 'message' => 'Search not authorized'] // 'message' is optional
        );
    }
}
```

When **show\_score** is enabled, you must add the field **\_scoreElastic** to the needed entities and add the field **getter** and **setter** (getScoreElastic &amp; setScoreElastic)

```
    private float $_scoreElastic;

    public function getScoreElastic(): float
    {
        return $this->_scoreElastic;
    }

    public function setScoreElastic(float $scoreElastic): self
    {
        $this->_scoreElastic = $scoreElastic;

        return $this;
    }
```

Configure index
---------------

[](#configure-index)

```
fos_elastica:
    indexes:
        user:
            properties:
                id:
                    type: keyword
                    index: true
                createdAt:
                    type:   date
            persistence:
                driver: orm
                model: App\Entity\User
                provider: ~
                finder: ~
                repository: Nzo\ElasticQueryBundle\Repository\SearchRepository
```

Populate index
--------------

[](#populate-index)

```
$ bin/console fos:elastica:populate
```

Payload Example
---------------

[](#payload-example)

POST [http://example.fr/search/myEnitity?page=1&amp;limit=2](http://example.fr/search/myEnitity?page=1&limit=2)

```
{
    "query": {
        "search": {
            "or": [
                {
                    "field": "status",
                    "match": "foo"
                },
                {
                    "field": "entity.title",
                    "notmatch": "bar"
                },
                {
                    "field": "entity.title",
                    "wildcard": "*toto*"
                },
                {
                    "and": [
                        {
                            "field": "lastname",
                            "notin": [
                                "titi",
                                "tata"
                            ]
                        },
                        {
                            "or": [
                                {
                                    "field": "age",
                                    "range": [
                                        20,
                                        30
                                    ]
                                },
                                {
                                    "field": "parent.age",
                                    "gte": 25
                                },
                                {
                                    "and": [
                                        {
                                            // This check is needed to make sure the 'parent' is not Null
                                            "field": "parent.id",
                                            "isnull": false
                                        },
                                        {
                                            "field": "parent.text",
                                            "isnull": true
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        "sort": [
            {
                "field": "createdAt",
                "order": "ASC"
            }
        ]
    }
}
```

License
-------

[](#license)

This bundle is under the MIT license. See the complete license in the bundle:

See [LICENSE](https://github.com/nayzo/NzoElasticQueryBundle/tree/master/LICENSE)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

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

Recently: every ~39 days

Total

30

Last Release

1627d ago

Major Versions

v1.4.0 → v2.0.02020-11-05

v2.0.8 → v3.0.02021-06-28

PHP version history (3 changes)v1.0.0PHP ^5.6.0|^7.1.3

v2.0.0PHP ^7.2.5

v3.0.0PHP &gt;=7.2.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/43973d4c7b23026540ed9f2670200cbd664d7ae7c55126feb465e62ba7a2a86f?d=identicon)[nayzo](/maintainers/nayzo)

---

Top Contributors

[![nayzo](https://avatars.githubusercontent.com/u/1272883?v=4)](https://github.com/nayzo "nayzo (54 commits)")

---

Tags

searchlanguagedataelasticsearchquery

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nzo-elastic-query-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/nzo-elastic-query-bundle/health.svg)](https://phpackages.com/packages/nzo-elastic-query-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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