2017 © Pedro Peláez
 

library elastica-specification

This library allows you to create Elastica queries using the Specification pattern

image

gbprod/elastica-specification

This library allows you to create Elastica queries using the Specification pattern

  • Thursday, February 22, 2018
  • by gbprod
  • Repository
  • 2 Watchers
  • 2 Stars
  • 8,386 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 10 % Grown

The README.md

Elastica specification

Build Status codecov Scrutinizer Code Quality Dependency Status, (*1)

Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

This library allows you to create Elastica queries using the specification pattern., (*3)

Usage

You can write specifications using gbprod/specification library., (*4)

Creates a elastica specification filter

namespace GBProd\Acme\Elastica\SpecificationFactory;

use GBProd\ElasticaSpecification\QueryFactory\Factory;
use GBProd\Specification\Specification;
use Elastica\QueryBuilder;

class IsAvailableFactory implements Factory
{
    public function create(Specification $spec, QueryBuilder $qb)
    {
        return $qb->query()->bool()
            ->addMust(
                $qb->query()->term(['available' => "0"]),
            )
        ;
    }
}

Configure

$registry = new GBProd\ElasticaSpecification\Registry();
$qb = new \Elastica\QueryBuilder();

$handler = new GBProd\ElasticaSpecification\Handler($registry, $qb);
$handler->registerFactory(IsAvailable::class, new IsAvailableFactory());
$handler->registerFactory(StockGreaterThan::class, new StockGreaterThanFactory());

Use it

$available = new IsAvailable();
$hightStock = new StockGreaterThan(4);

$availableWithLowStock = $available
    ->andX(
        $hightStock->not()
    )
;

$type = $this->elasticaClient
    ->getIndex('my_index')
    ->getType('my_type')
;

$query = $handler->handle($availableWithLowStock)

$results = $type->search($query);

Requirements

  • PHP 7.0+

Installation

Using composer

composer require gbprod/elastica-specification

The Versions

22/02 2018

dev-master

9999999-dev

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT WTFPL

The Requires

 

The Development Requires

by Avatar gbprod

22/02 2018

dev-chore/licence

dev-chore/licence

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

WTFPL

The Requires

 

The Development Requires

by Avatar gbprod

08/02 2018

v2.1.0

2.1.0.0

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

01/02 2018

dev-feat/elastica6

dev-feat/elastica6

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

26/06 2017

v2.0.0

2.0.0.0

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

26/06 2017

v1.1.0

1.1.0.0

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

26/06 2017

v1.1.x-dev

1.1.9999999.9999999-dev

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

31/12 2016

v1.0.0

1.0.0.0

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

28/12 2016

v1.0-beta.0

1.0.0.0-beta0

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

12/09 2016

v0.2.0

0.2.0.0

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

06/09 2016

v0.1.1

0.1.1.0

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

04/09 2016

v0.1.0

0.1.0.0

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

04/09 2016

v0.1-alpha.1

0.1.0.0-alpha1

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

04/09 2016

v0.1-alpha.0

0.1.0.0-alpha0

This library allows you to create Elastica queries using the Specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gilles