首页 > 解决方案 > ONGR Elasticsearch Bundle AWS Connection Issue

问题描述

Hello Ther i try to connenct to ES indet that is located on AWS, but i still get he Error. [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
You have requested a non-existent service "es.managers.default".

I installed the bundle using Conposer, as described on the Docs. then added a config part tom my config.ylm

ongr_elasticsearch:
managers:
    default:
        index:
            index_name: contents
            hosts:
                - https://search-***.es.amazonaws.com:443
            mappings:
                - StatElasticBundle

i have a awsaccesskey and a awssecretkey, but i don't now where i have to put them, so i created a aws_connection section in the parameters.yml and try to load it

Then i try to establish a connection in my SymfonyBundle and created a class in my Bundle->DepandencyInjection folder to extend my bundle, this is where i get the error. Mayby someone of you struggled with the same error? Thanks for help.

Class StatElasticExtension extends Extension
{
    const YAML_FILES = [
        'parameters.yml',
        'config.yml',
        'services.yml'
    ];

    /**
     * {@inheritdoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        foreach (self::YAML_FILES as $yml) {
            $loader->load($yml);
        }

        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        $serviceDefinition = $container->getDefinition('es.managers.default');
        $awsConnections = $container->getParameter('aws_connections');
        $elasticsearchClient = $this->getClient($awsConnections);
        $serviceDefinition->replaceArgument(2, $elasticsearchClient);
    }

标签: symfonyelasticsearchongr

解决方案


正确的服务名称是es.manager.default.


推荐阅读