DEV Community

Mustafa Hussain
Mustafa Hussain

Posted on

Introducing Elasticsearch repository php package

Elasticsearch active repository package

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

Features

  • provide active repository pattern over your elasticsearch indices, types.
  • Minimize lines of code for building elasticsearch queries with system with big business logic.
  • Prevent code duplication.
  • Reduce potential programming errors.
  • Apply centrally managed, consistent access rules and logic.
  • Improve the code’s maintainability and readability by separating client objects from domain models.
  • Maximize the amount of code that can be tested with automation and to isolate both the client object and the domain model to support unit testing.

installation

grap it via composer

composer require mustafah15/elastic-repository

Enter fullscreen mode Exit fullscreen mode

ElasticRepository contains a queryBuilder object for getting result from elasticsearch in effective way example for using queryBuilder inside your repository


public function getStudent($name, $class) {
    $this->queryBuilder->match('name', $name)->where('class', $class)->get();
}   
Enter fullscreen mode Exit fullscreen mode

For full documentation check github repository

Top comments (1)

Collapse
 
azazqadir profile image
Muhammad Azaz Qadir

Elasticsearch is great for improving the speed of searching on PHP website. However, it is not necessary to use any package for that. You can simply use Elasticsearch PHP API for integrating it on your website.