PHPackages                             darklow/ff-elastica-manager - 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. [Search &amp; Filtering](/categories/search)
4. /
5. darklow/ff-elastica-manager

ActiveLibrary[Search &amp; Filtering](/categories/search)

darklow/ff-elastica-manager
===========================

Elastica manager for creating, rotating, populating and managing ElasticSearch indexes using Elastica client library

2552[1 PRs](https://github.com/darklow/ff-elastica-manager/pulls)PHP

Since Nov 19Pushed 12y ago2 watchersCompare

[ Source](https://github.com/darklow/ff-elastica-manager)[ Packagist](https://packagist.org/packages/darklow/ff-elastica-manager)[ RSS](/packages/darklow-ff-elastica-manager/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

FF-Elastica-Manager
===================

[](#ff-elastica-manager)

FF-Elastica-Manager is php library for creating, rotating, populating and managing ElasticSearch indexes using [Elastica client](https://github.com/ruflin/Elastica) library.

### Work in progress

[](#work-in-progress)

This package is still under development, however these features are already implemented

Features
--------

[](#features)

- Index creation with user config and mapping
- Index data population using data provider
- One document update/insert/delete
- Index utils: delete, indexExists, addAlias, removeAlias
- Iterator. Batch iterator iterates through index data (using ES scan/scroll functionality) and performs user specified closure
- Examples: ShopConfiguration.php, ShopDataProvider.php [Go to example directory](https://github.com/darklow/ff-elastica-manager/tree/master/example)

**Todo**: Index copy/clone, index rotate (copy and change alias), Symfony2 Console component commands

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

[](#installation)

The recommended way to install package is [through composer](http://getcomposer.org). Create a `composer.json` in your project root-directory:

```
{
    "require": {
        "darklow/ff-elastica-manager": "*"
    }
}

```

and run `curl -s http://getcomposer.org/installer | php` to get composer or run `php composer.phar install` to install package

Overview
--------

[](#overview)

ElasticaManager package contains of following classes:

1. **ElasticaManager** - working with indexes and elasticsearch server
2. **IndexManager** - create, delete, manage specific index
3. **Batch Iterator** - iterates through index data (using ES scan/scroll functionality) and performs user specified closure

For every index you want to manage, you have to create two classes:

1. **Configuration** - Configuration class which provides necessary info for ElasticSearch index:

    - Index default name - default name of the index (can be overridden on IndexManager initiation)
    - Index default alias name
    - Index types - ElasticSearch index type name(s)
    - Index configuration - number of shards and replicas, analysis analyzers and filters
    - Mapping properties - fields and its types for each/all ElasticSearch type
    - Mapping params - params like `_all => [ enabled => false]` and so on
2. **DataProvider** - Data provider class which provides all the data needed to populate whole index or just one document. Following methods must be implemented:

    - getData($typeName = null) - Method must return iterable result/array for all the data or one type only if specified
    - iterationRowTransform($data, $typeName = null) - Method must convert iteration row data to DataProviderDocument object which contains three variables
        - id - DocumentID
        - typeName - ElasticSearch index type name
        - data - Array for document source data
    - getTotal($typeName = null) - Optional method. Must return count for all the data or one type only if specified used. Used for iteration closures.
    - getIterationClosure() - Optional method. Must return callback for iteration: function ($i, $total)
    - getDocumentData() - Method must return same type of data as one iteration row in getData()

Example of both classes can be found in [example directory](https://github.com/darklow/ff-elastica-manager/tree/master/example)

When you have setup up everything, working with indexes is really easy:

### IndexManager Example

[](#indexmanager-example)

```
