2017 © Pedro Peláez
 

package elastic

elastic search active repository package

image

aqarmap/elastic

elastic search active repository package

  • Wednesday, July 25, 2018
  • by aqarmap
  • Repository
  • 8 Watchers
  • 0 Stars
  • 2,358 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 2063 % Grown

The README.md

Packagist License, (*1)

:tada: Elasticsearch Repository Package

Elasticsearch Repository is a simple, smart implementation of Active Repository for Elasticsearch., (*2)

: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.

:grey_exclamation: Installation

grap it via composer, (*3)

composer require mustafah15/elastic-repository

integration

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

: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();
    }
}

:clipboard: Documentation

ElasticRepository

when you extend ElasticRepository class you will have get various functionality, (*5)

setIndex(), setType()

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

setSort()

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

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

setOrder()

The setOrder() method to specify sort direction:, (*8)

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

setTransformer($transformer)

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

get()

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

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, (*11)

getResultQuery()

the getResultQuery() return Query object, (*12)

getResultQueryWithScore($scoreFunction)

takes Query\FunctionScore $functionScore as a parameter to apply scoring to your query, (*13)

QueryBuilder

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

where(), whereNot()

The where() and whereNot() methods adding must and must not to the main filter:, (*15)

//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:, (*16)


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

exist('fieldName')

$queryBuilder->exist('fieldName');

match($attribute, $keyword)

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

TODO

  • caching support

Contributing

Please see CONTRIBUTING for details., (*17)

License

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

The Versions

25/07 2018

dev-master

9999999-dev

elastic search active repository package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aqarmap

25/07 2018

1.03

1.03.0.0

elastic search active repository package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aqarmap

10/05 2018

1.02

1.02.0.0

elastic search active repository package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aqarmap

10/05 2018

1.01

1.01.0.0

elastic search active repository package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aqarmap

05/04 2018

1.0

1.0.0.0

elastic search active repository package

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar aqarmap