Skip to content

feat(elasticsearch): OpenSearch support#7811

Merged
soyuka merged 3 commits intoapi-platform:mainfrom
hotfix31:feat/opensearch-support
Mar 2, 2026
Merged

feat(elasticsearch): OpenSearch support#7811
soyuka merged 3 commits intoapi-platform:mainfrom
hotfix31:feat/opensearch-support

Conversation

@hotfix31
Copy link
Contributor

@hotfix31 hotfix31 commented Mar 1, 2026

Q A
Branch? main
Tickets #7519
License MIT
Doc PR api-platform/docs#2259

Hello,

Following up on #7519 — here's my take at adding OpenSearch support to the Elasticsearch bridge.

Given how similar the two clients are, it felt much simpler to patch the existing bridge rather than create a separate bundle that would have been little more than a copy with very little added value.

The idea is pretty simple: a new client option under api_platform.elasticsearch that accepts either "elasticsearch" (default, nothing changes) or "opensearch". When set to "opensearch", the bridge uses opensearch-project/opensearch-php instead of the Elasticsearch client. The package is declared as a suggest so it stays fully optional.

On the code side, ElasticsearchClientPass builds the client through OpenSearch\ClientBuilder::fromConfig when configured, and both CollectionProvider and ItemProvider now accept OpenSearch\Client and catch its Missing404Exception. The rest is config wiring and validation.

Configuration looks like this:

api_platform:
    elasticsearch:
        enabled: true
        client: opensearch
        hosts:
            - '%env(OPENSEARCH_URL)%'

CI-wise I added a PHPUnit matrix entry running the elasticsearch component tests with pensearch-php installed, plus a Behat job against an OpenSearch 2.19.4 container. Everything is green and existing Elasticsearch tests are unaffected. Full transparency: I'm not very familiar with GitHub Actions so Claude Code helped me a lot on that part.

Happy to adjust anything based on your feedback!

Fred

@hotfix31 hotfix31 force-pushed the feat/opensearch-support branch from f74d7ba to 1eeea25 Compare March 1, 2026 21:22
Copy link
Member

@soyuka soyuka left a comment

Choose a reason for hiding this comment

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

wow really nice addition! Thanks!

@soyuka soyuka changed the title feat(elasticsearch): add OpenSearch support feat(elasticsearch): OpenSearch support Mar 2, 2026
@soyuka soyuka merged commit 516ee3a into api-platform:main Mar 2, 2026
149 of 151 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.

2 participants