Elastic Repository

Elasticsearch Active Repository Package
Alternatives To Elastic Repository
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Bodybuilder1,21810558a month ago65May 21, 20229mitJavaScript
An elasticsearch query body builder :muscle:
Elastic Builder460161613 days ago58June 05, 202116mitJavaScript
A Node.js implementation of the elasticsearch Query DSL :construction_worker:
a year ago7apache-2.0Go
An idiomatic Go query builder for ElasticSearch
8 years ago13apache-2.0Java
A javascript shell for elasticsearch
2 years ago53December 15, 20213mitPython
A simple (Python) query builder for Elasticsearch
Wpes Lib67
3 years agogpl-2.0PHP
WordPress-Elasticsearch Lib
Q Builders48422 years ago7June 23, 20172mitJava
Type safe database agnostic query builders.
Fast Elasticsearch Query Builder47
4 years agoapache-2.0Java
A fast way to build ElasticSearch query string, even without writing implement code.
Spring Data Elasticsearch47
7 years ago2HTML
Elasticsearch Query Builder37
a month ago2mitPHP
Build query for an ElasticSearch client using a fluent interface
Alternatives To Elastic Repository
Select To Compare

Alternative Project Comparisons

Packagist License

🎉 Elasticsearch Repository Package

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

🔥 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

grap it via composer

composer require mustafah15/elastic-repository


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

✨ 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


when you extend ElasticRepository class you will have get various functionality

setIndex(), setType()

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


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 


The setOrder() method to specify sort direction:



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


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


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


the getResultQuery() return Query object


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


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

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()

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 = '');



match($attribute, $keyword)

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


  • add the rest of crud operation (insert, update)
  • caching support


Please see CONTRIBUTING for details.


The MIT License (MIT). Please see License File for more information.

Popular Elasticsearch Projects
Popular Builder Projects
Popular Data Storage Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Query Builder