OpenSearch is an open-source search and analytics engine forked from Elasticsearch. It's compatible with Elasticsearch APIs and can be used as an alternative.
Enable OpenSearch during the initial setup:
dev setupIf you've already set up your environment, enable OpenSearch by creating a configuration marker:
mkdir -p conf/opensearch
dev rebuildOpenSearch is available at:
- Host:
opensearch - Port:
9200 - Security: Disabled by default (development environment)
OpenSearch is API-compatible with Elasticsearch and can be used as a drop-in replacement. Key differences:
- Open-source license (Apache 2.0)
- Active community development
- Compatible with existing Elasticsearch clients
- Security plugins available
Verify OpenSearch is running:
dev console curl -X GET "opensearch:9200/_cluster/health?pretty"Create an index:
dev console curl -X PUT "opensearch:9200/my-index"Index a document:
dev console curl -X POST "opensearch:9200/my-index/_doc" -H 'Content-Type: application/json' -d '{"field": "value"}'Search:
dev console curl -X GET "opensearch:9200/my-index/_search?q=field:value"Use the hostname opensearch and port 9200:
$client = new OpenSearch\Client([
'hosts' => ['opensearch:9200']
]);In your env.php:
'system' => [
'default' => [
'catalog' => [
'search' => [
'engine' => 'opensearch',
'opensearch_server_hostname' => 'opensearch',
'opensearch_server_port' => '9200'
]
]
]
]For a web-based interface, see opensearch-dashboard.md.
Check if OpenSearch is running:
dev ps | grep opensearchView OpenSearch logs:
dev logs opensearchIf you need both OpenSearch and Elasticsearch, you cannot run them simultaneously on the same port. Choose one for your project.