ppokatilo / elastica-entity-mapping-bundle
Automatically updates elasticsearch mappings
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=5.5.0
- doctrine/annotations: 1.*
- ppokatilo/project-scanner: ~1.0
- psr/log: ~1.0
- ruflin/elastica: *
- symfony/config: ~2.0
- symfony/dependency-injection: ~2.0
- symfony/finder: ~2.0
- symfony/http-kernel: ~2.0
This package is not auto-updated.
Last update: 2024-11-05 04:49:50 UTC
README
An Symfony2 bundle that automatically updates your Elasticsearch mappings or notifies you of changes.
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.
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.
Example usage
-
app/AppKernel.php
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
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
/** * @ElasticsearchMapping(file="./example_entity.json", indices="dev,other") **/ class ExampleEntity { // ... }