gbprod/elastica-extra-bundle

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

Bundle providing extra elastica tools for managing indices and types settings

v1.1.0 2018-01-23 11:05 UTC

This package is auto-updated.

Last update: 2021-08-07 10:20:23 UTC


README

Build Status codecov Scrutinizer Code Quality Dependency Status

Latest Stable Version Total Downloads Latest Unstable Version License

Bundle providing extra elastica tools for managing indices and types settings.

With this bundle you can :

  • Manage index settings and mappings in yaml
  • Create and delete index
  • Manage indices' aliases
  • Reindex

Installation

With composer :

composer require gbprod/elastica-extra-bundle

Update your app/AppKernel.php file:

public function registerBundles()
{
    $bundles = array(
        new GBProd\ElasticaExtraBundle\ElasticaExtraBundle(),
    );
}

Configure Elastica client

gbprod_elastica_extra:
    default_client: 'elastica.default_client' # Elastica client service's name

You can create Elastica client using a bundle like:

  • FOSElasticaBundle Service name will look like fos_elastica.client.my_client
  • My lightweight bundle ElasticaBundle Service name will look like elastica.default_client
  • DIY

Index Management Operations

Configuration

Set indices setup

elastica_extra:
    default_client: 'elastica.default_client'
    indices:
        my_index:
            settings:
                number_of_shards: 3
                number_of_replicas: 2
            mappings:
                my_type:
                    _source:
                        enabled: true
                    properties:
                        first_name:
                            type: string
                            analyzer: standard
                        age:
                            type: integer
        my_index_2: ~

Create index

Will create index using his configuration.

php app/console elasticsearch:index:create my_index

Will create index using another index configuration (usefull when using aliases)

php app/console elasticsearch:index:create my_versionned_index --alias=my_index

Delete index

php app/console elasticsearch:index:delete my_index --force

Put index settings

php app/console elasticsearch:index:put_settings my_index

Will put index settings using another index configuration (usefull when using aliases)

php app/console elasticsearch:index:put_settings my_versionned_index --alias=my_index

Put index mappings

php app/console elasticsearch:index:put_mappings my_index my_type

Will put index mappings using another index configuration (usefull when using aliases)

php app/console elasticsearch:index:put_mappings my_versionned_index my_type --alias=my_index

Aliases Management Operations

List aliases for an index

php app/console elasticsearch:alias:list my_index

Add alias for an index

php app/console elasticsearch:alias:add my_index my_alias

If --replace options is set, an existing alias will be replaced

php app/console elasticsearch:alias:add my_index my_alias --replace

Remove alias for an index

php app/console elasticsearch:alias:remove my_index my_alias

List indices

This command list indices

php app/console elasticsearch:index:list

You also can filter displayed indices using regex

php app/console elasticsearch:index:list --pattern="user*"

Reindex

This command reindex using reindex api

php app/console elasticsearch:reindex [old-index] [new-index]

Use a different client

For all commands you can specify a different client using --client option.

eg:

php app/console elasticsearch:index:create my_index --client=my_client_service