OpenSearch "server is not a supported distribution" from the Elasticsearch client in CI
Newer official Elasticsearch clients check the server product header and refuse to run against anything that is not Elasticsearch, throwing "the server is not a supported distribution". OpenSearch forked from Elasticsearch, so the Elasticsearch client rejects it. The fix is to use the OpenSearch client, not the Elasticsearch one.
What this error means
Against an OpenSearch service container, the Elasticsearch client throws "The client noticed that the server is not a supported distribution. This functionality is not supported ...".
elasticsearch.UnsupportedProductError: The client noticed that the server is not
Elasticsearch and we do not support this unknown productCommon causes
The Elasticsearch client enforces a product check
Recent Elasticsearch clients verify the X-elastic-product header and refuse to operate against a non-Elasticsearch server such as OpenSearch.
The test uses the wrong client for the server
The service container runs OpenSearch, but the test imports the Elasticsearch client library, so the two are incompatible.
How to fix it
Use the OpenSearch client
- Install the OpenSearch client for your language (for example
opensearch-py). - Point it at the OpenSearch service container.
- Replace the Elasticsearch client import in the tests.
from opensearchpy import OpenSearch
client = OpenSearch(hosts=[{"host": "localhost", "port": 9200}])
client.cluster.health(wait_for_status="yellow")Match the client to the server product
Run the Elasticsearch client against Elasticsearch and the OpenSearch client against OpenSearch; do not mix them, since the product check blocks the mismatch.
How to prevent it
- Choose the client that matches the server distribution.
- When migrating from Elasticsearch to OpenSearch, switch client libraries too.
- Pin the client so a version bump does not add or change the product check unexpectedly.