2017 © Pedro Peláez
 

symfony-bundle elastica-entity-mapping-bundle

Automatically updates elasticsearch mappings

image

ppokatilo/elastica-entity-mapping-bundle

Automatically updates elasticsearch mappings

  • Monday, March 16, 2015
  • by SHyx0rmZ
  • Repository
  • 1 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 14 Versions
  • 0 % Grown

The README.md

elastica-entity-mapping-bundle

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

An Symfony2 bundle that automatically updates your Elasticsearch mappings or notifies you of changes., (*2)

How it works

An elastica client service is modified to be constructed using a factory. The factory reads Composer's autoload files to know about all your dependencies. It will then scan each directory for a subdirectory called Entity and search the PHP files in that subdirectory for the @ElasticsearchMapping annotation., (*3)

When instantiating the elastica client service, the factory will first check if the mapping of registered entities on disk differs from that in Elasticsearch. If so, it will either throw an exception or try to update the mapping automatically., (*4)

Example usage

  • app/AppKernel.php, (*5)

    class AppKernel extends Kernel
    {
    public function registerBundles()
    {
        $bundles = array(
          // ...
        );
    
        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new SHyx0rmZ\ElasticaEntityMapping\ElasticaEntityMappingBundle();
        }
    
        return $bundles;
    }
    }
    
    // ...
    
  • app/config/config_dev.yml, (*6)

    elastica_entity_mapping:
    clients:
      -
        service: elastica.client
        update: false # throw exceptions instead of updating mapping automatically
        indices:
          -
            name: %elastica_index_name%
            alias: dev
            settings: vendor/example/entitybundle/settings.json
          -
            name: my_other_index
            alias: other
    
  • vendor/example/entitybundle/ExampleEntity.php, (*7)

    /**
    * @ElasticsearchMapping(file="./example_entity.json", indices="dev,other")
    **/
    class ExampleEntity
    {
    // ...
    }
    

The Versions

22/11 2014
21/11 2014