This package is abandoned and no longer maintained. No replacement package was suggested.

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

v2.1.0 2018-02-26 09:35 UTC

This package is auto-updated.

Last update: 2021-08-07 10:31:34 UTC


Build Status codecov Scrutinizer Code Quality Dependency Status

Latest Stable Version Total Downloads Latest Unstable Version License

This library allows you to create Algolia queries using the specification pattern.


You can write specifications using gbprod/specification library.

Creates a algolia specification filter

@see Algolia documentation

namespace GBProd\Acme\Algolia\SpecificationFactory;

use GBProd\AlgoliaSpecification\QueryFactory\Factory;
use GBProd\Specification\Specification;

class IsAvailableFactory implements Factory
    public function create(Specification $spec)
        return 'available=1';


$registry = new GBProd\AlgoliaSpecification\Registry();

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

Use it

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

$availableWithLowStock = $available
$client = new \AlgoliaSearch\Client('YourApplicationID', 'YourAPIKey');
$index = $client->initIndex('index_name');

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

$results = $type->search(['filters' => $query]);


  • PHP >= 7.0


Using composer

composer require gbprod/algolia-specification