Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

Kenneth-Sills
Copy link
Contributor

Closes #500

@@ -292,7 +292,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
$factory = class_exists('Elastic\Elasticsearch\ClientBuilder') ? 'Elastic\Elasticsearch\ClientBuilder' : 'Elasticsearch\ClientBuilder';
$client->setFactory([$factory, 'fromConfig']);
$clientArguments = [
'host' => $handler['elasticsearch']['host'],
'hosts' => [$handler['elasticsearch']['host']],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not valid. The arguments need to be different for V7 or v8 (see just above where we already detect version 8+ for other differences)

Copy link
Contributor Author

@Kenneth-Sills Kenneth-Sills Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I said in the ticket, this applies to both v7 and v8. ClientBuilder::fromConfig works the same in both versions by proxying to the set* method and the only such method that exists is setHosts, not setHost.

In my demo project I just ran composer require elasticsearch/elasticsearch=^7 (using Elastica, so no v8), then set the monolog config like:

  monolog:
    handlers:
      main:
        type: fingers_crossed
        handler: elastic_search
        action_level: error
        excluded_http_codes: [404, 405]
        buffer_size: 50
      elastic_search:
        type: elastic_search
        elasticsearch:
          host: '%elastic_domain%'
          port: '%elastic_port%'
        index: '%elastic_index_monolog%'

Finally, I ran ./bin/console cache:clear (after rm -rf var/cache/* for good measure). And it also fails with:

In ClientBuilder.php line 217:

  Unknown parameters provided: host  

So far as I can tell this has always been the case in that client (though I only checked to v5). I think we just accidentally assumed the parameter was the same as Elastica at the time of implementation.

You are correct when it comes to Elastica, though, which I noted here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stof Bump!

(Let me know if y'all don't like bumps.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the method ClientBuilder::fromConfig of all versions of elasticsearch-php, I see that the parameter has always been the plural hosts. This update looks good to me.

The PR needs to be rebased on 3.x.

@GromNaN GromNaN changed the base branch from 4.x to 3.x October 12, 2025 08:35
@GromNaN GromNaN force-pushed the kesills-500-elasticsearch branch from a9be50c to e70641d Compare October 13, 2025 13:22
@GromNaN GromNaN force-pushed the kesills-500-elasticsearch branch from e70641d to cae1fb8 Compare October 13, 2025 13:26
@GromNaN
Copy link
Member

GromNaN commented Oct 13, 2025

Thanks for fixing this bug @Kenneth-Sills.

@GromNaN GromNaN merged commit f78fcaf into symfony:3.x Oct 13, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

elastic_search Handler Does Not Work (Invalid Factory Parameters)

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.