DEV Community

selfhosting.sh
selfhosting.sh

Posted on • Originally published at selfhosting.sh

Elasticsearch vs OpenSearch: Compared

Quick Verdict

OpenSearch is the better choice for most self-hosters. It includes security, alerting, and anomaly detection for free — features that Elasticsearch partially gates behind paid tiers. The API is nearly identical (OpenSearch forked from Elasticsearch 7.10.2), so most tools work with both. Choose Elasticsearch only if you need the latest Elastic-specific features or tight integration with the official Elastic Stack.

Overview

OpenSearch is Amazon's fork of Elasticsearch, created in 2021 after Elastic changed Elasticsearch's license from Apache 2.0 to SSPL/Elastic License. In August 2024, Elastic relicensed Elasticsearch again — this time under AGPL v3 (alongside SSPL and Elastic License 2.0 as options). Both are distributed search and analytics engines based on Apache Lucene.

Elasticsearch — AGPL v3 (also available under SSPL or Elastic License 2.0, your choice). The original. Created by Elastic. Most widely used search engine. Powers the ELK Stack (Elasticsearch, Logstash, Kibana). Core features are free; some advanced features require a paid subscription.

OpenSearch — Apache 2.0. Amazon's fork from Elasticsearch 7.10.2. Governed by the OpenSearch Software Foundation. All features are free and open source, including security, alerting, and machine learning.

Feature Comparison

Feature Elasticsearch OpenSearch
License AGPL v3 (or SSPL / Elastic License 2.0) Apache 2.0
Security (auth, TLS, RBAC) Free (covers most self-hosting needs) Free (built-in)
Alerting Paid (Watcher) Free (built-in)
Anomaly detection Paid (ML) Free (built-in)
SQL query support Free (basic) Free (built-in)
Index management Free (ILM) Free (ISM)
Cross-cluster replication Paid Free
Dashboard/visualization Kibana (Elastic License) OpenSearch Dashboards (Apache 2.0)
Machine learning Paid Free (basic)
Query DSL Full Elasticsearch DSL Compatible (7.10.2 base + extensions)
REST API compatibility Native ~95% Elasticsearch compatible
Aggregations Full pipeline aggs Full pipeline aggs
Horizontal scaling Yes (shards, replicas) Yes (shards, replicas)
Vector search (k-NN) Yes Yes (FAISS, Lucene, nmslib)
Observability Free (APM, traces, metrics) Free (trace analytics)
Performance Generally faster Improving, ~10-40% slower in benchmarks
Managed cloud offering Elastic Cloud AWS OpenSearch Service
Docker image docker.elastic.co/elasticsearch/elasticsearch opensearchproject/opensearch
Default port 9200 9200

Installation Complexity

Elasticsearch single-node setup:

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.19.11
    container_name: elasticsearch
    ports:
      - "9200:9200"
    volumes:
      - es_data:/usr/share/elasticsearch/data
    environment:
      - discovery.type=single-node
      - xpack.security.enabled=false
      - ES_JAVA_OPTS=-Xms1g -Xmx1g
    ulimits:
      memlock:
        soft: -1
        hard: -1
    restart: unless-stopped

volumes:
  es_data:
Enter fullscreen mode Exit fullscreen mode

Security is enabled by default in Elasticsearch 8.x. Disabling it (as shown) simplifies development setup but isn't recommended for production. When enabled, Elasticsearch auto-generates TLS certificates and the elastic user password on first boot.

For quick local testing, Elastic provides start-local — a single command that spins up Elasticsearch and Kibana with sensible defaults. Run curl -fsSL https://elastic.co/start-local | sh to get a working instance in seconds without writing any Docker Compose configuration.

OpenSearch single-node setup:

services:
  opensearch:
    image: opensearchproject/opensearch:3.5.0
    container_name: opensearch
    ports:
      - "9200:9200"
    volumes:
      - os_data:/usr/share/opensearch/data
    environment:
      - discovery.type=single-node
      - OPENSEARCH_INITIAL_ADMIN_PASSWORD=YourStr0ngP@ssword!
      - OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g
      - plugins.security.disabled=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
    restart: unless-stopped

volumes:
  os_data:
Enter fullscreen mode Exit fullscreen mode

Setup complexity is nearly identical. Both require JVM tuning, vm.max_map_count=262144 on the host, and similar configuration. OpenSearch requires OPENSEARCH_INITIAL_ADMIN_PASSWORD to be set even when security is disabled.

Performance and Resource Usage

Both are Java applications running on the JVM with similar baseline requirements:

  • Minimum RAM: 1-2 GB JVM heap per node
  • Recommended RAM: 4+ GB for production
  • Disk: SSD recommended for indexing performance

Elasticsearch generally benchmarks 10-40% faster than OpenSearch for equivalent queries and indexing workloads. Elastic invests heavily in Lucene optimizations that take time to be adopted by OpenSearch.

OpenSearch has been closing the performance gap with each release. For most self-hosted use cases (under 100M documents, moderate query volume), the performance difference is imperceptible.

Both consume similar RAM and CPU for equivalent workloads. The performance difference primarily matters at enterprise scale.

Community and Support

Elasticsearch: The industry standard. Decades of documentation, tutorials, and Stack Overflow answers. Commercial support from Elastic. Massive ecosystem of integrations. Kibana is the gold standard for search visualization.

OpenSearch: Growing community under the OpenSearch Software Foundation. Good documentation. AWS provides commercial support. OpenSearch Dashboards is a capable Kibana alternative. Increasing adoption among organizations concerned about licensing.

Elasticsearch has the larger community and more mature tooling. OpenSearch has momentum among organizations that want truly open-source infrastructure.

Use Cases

Choose OpenSearch If...

  • You want all features free and open source (security, alerting, ML)
  • Licensing matters — Apache 2.0 is simpler than Elasticsearch's triple-license (AGPL/SSPL/ELv2)
  • You need cross-cluster replication without paying for a license
  • You want to avoid vendor lock-in with Elastic
  • You're building a SaaS product (AGPL's copyleft and SSPL's restrictions may complicate hosted offerings)
  • You're replacing an existing Elasticsearch 7.x deployment

Choose Elasticsearch If...

  • You need the latest Elasticsearch-specific features
  • You want the fastest possible search performance
  • You need tight Kibana integration with all plugins
  • You're using Elastic APM, Elastic Agent, or Fleet
  • You have existing Elastic Stack infrastructure
  • You need commercial support from Elastic

Final Verdict

OpenSearch is the better choice for most self-hosters. The Apache 2.0 license means no surprises. Security, alerting, and anomaly detection are free. The API is compatible with Elasticsearch 7.x tooling. For self-hosted search and log aggregation, OpenSearch gives you more features for free.

Elasticsearch is the better choice if you need cutting-edge features or the full Elastic Stack. If you're deep in the Elastic ecosystem (Kibana, Beats, Elastic Agent, APM), switching to OpenSearch means giving up tight integration. Elasticsearch also maintains a performance edge in benchmarks.

For a new self-hosted search deployment with no existing Elastic infrastructure: start with OpenSearch.

Related

Top comments (0)