PHPackages                             violet88/silverstripe-elastica - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. violet88/silverstripe-elastica

ActiveSilverstripe-vendormodule[API Development](/categories/api)

violet88/silverstripe-elastica
==============================

Module for Silverstripe to use Elastic Search

4.x-dev(3y ago)053BSD-3-ClausePHPPHP ^7.4 || ^8.0

Since Mar 16Pushed 3y agoCompare

[ Source](https://github.com/Violet88github/silverstripe-elastica)[ Packagist](https://packagist.org/packages/violet88/silverstripe-elastica)[ RSS](/packages/violet88-silverstripe-elastica/feed)WikiDiscussions 4 Synced 1mo ago

READMEChangelogDependencies (6)Versions (1)Used By (0)

Silverstripe Elastica Module
============================

[](#silverstripe-elastica-module)

Installation
------------

[](#installation)

Run the following command to install the module:

```
composer require violet88/silverstripe-elastica
```

Configuration
-------------

[](#configuration)

Add the following to a file called dependencies.yml

```
SilverStripe\Core\Injector\Injector:
  Elastica\Client:
    constructor:
      - host: '`ELASTICA_HOST`'
        port: '`ELASTICA_PORT`'
        transport: ''
        username: ''
        password: '>'
        auth_type: '>'
  Violet88\Elastica\Tasks\ReindexTask:
    constructor:
      - '%$Violet88\Elastica\Services\ElasticaService'
  Violet88\Elastica\Extensions\Searchable:
    constructor:
      - '%$Violet88\Elastica\Services\ElasticaService'
  Violet88\Elastica\Services\ElasticaService:
    constructor:
      - '%$Elastica\Client'
      - ''
```

And add the following to your \_config.php:

```
if (!empty(Environment::getEnv('ELASTICASERVICE_INDEX'))) {
    Config::modify()->set('Injector', 'Violet88\Elastica\Services\ElasticaService', [
        'constructor' => [
            '%$Elastica\Client',
            Environment::getEnv('ELASTICASERVICE_INDEX'),
            isset($env['ElasticaService']['config']) ? $env['ElasticaService']['config'] : null
        ]
    ]);

    // register Searchables
    if (!empty(Environment::getEnv('ELASTICASERVICE_SEARCHABLE'))) {
        foreach (unserialize(Environment::getEnv('ELASTICASERVICE_SEARCHABLE')) as $class) {
            $class::add_extension('Violet88\Elastica\Extensions\Searchable');
        }
    }
}
```

Add the following to your environment variables:

```
ELASTICASERVICE_INDEX=''
ELASTICASERVICE_SEARCHABLE=''
ELASTICA_HOST='
