Internative Logo

What Is Elasticsearch? Search and Analytics Engine Explained

What Is Elasticsearch? Search and Analytics Engine Explained

A search box looks simple until users start typing into it. They misspell product names, search in plural and singular, expect the best match first and want results filtered by brand, price band and size in the same breath. A relational database can answer LIKE '%term%', but it cannot rank by relevance or search millions of documents for every keystroke. Elasticsearch was built for exactly that, and the same engine turned out to be just as good at searching through billions of log lines.

This article explains what Elasticsearch is, how it works, where it is used, how its licence has changed, when it is the right tool and how it compares with OpenSearch, Solr and database full-text search.

What is Elasticsearch?

Elasticsearch is a distributed search and analytics engine built on Apache Lucene, the Java search library, and is itself written in Java. It stores data as JSON documents, indexes every field, and lets you search and aggregate them through a REST API, usually in milliseconds and in near real time after the data is written.

Shay Banon released the first version in February 2010. He had earlier built Compass, a library that made Lucene easier to use from Java, and designed Elasticsearch as its distributed successor: a search server that speaks JSON over HTTP, so any programming language can use it, and that spreads data over many machines. In 2012 he and others founded the company now called Elastic to develop it. Elasticsearch became the centre of the Elastic Stack, together with Kibana for visualisation and Logstash and Beats for collecting data, a combination long known as the ELK stack.

Licence history. Elasticsearch was originally released under the Apache License 2.0. In 2021, with version 7.11, Elastic moved the source code to a dual licence, the Server Side Public License (SSPL) and the Elastic License 2.0, mainly to stop cloud providers offering it as a service without contributing back. In response, AWS forked the last Apache-licensed version and created OpenSearch, which moved to the Linux Foundation's OpenSearch Software Foundation in September 2024. In August 2024 Elastic announced that it would add the AGPLv3, an OSI-approved open-source licence, as a third option, which took effect from version 8.16. Elastic's own distribution is still published under the Elastic License, with free and paid features.

How Elasticsearch works

Documents, indices and mappings. Data is stored as JSON documents in an index. A mapping defines each field's type, such as text, keyword, number, date, geo-point or vector, and how text fields are analysed. Elasticsearch can infer mappings automatically, but production systems usually define them explicitly.

The inverted index. For text fields, Elasticsearch builds an inverted index: a list of every term and the documents that contain it, like the index at the back of a book. Searching for a word becomes a lookup, not a scan. Before indexing, an analyser splits text into tokens, lowercases them and can apply stemming, synonyms and language rules, so "running" can match "run".

Relevance scoring. Results are ranked, by default with the BM25 algorithm, which weighs how often a term appears in a document against how common it is across all documents. Queries can boost fields, combine conditions and apply custom scoring.

Shards, replicas and clusters. An index is split into primary shards, each a self-contained Lucene index, and each shard can have replicas on other nodes. Shards spread data and query load across the cluster; replicas protect against node failure and serve reads.

Near real time. New documents become searchable after a refresh, which by default happens every second. That is fast enough for most search and logging, but it means a document you just wrote may not appear in a search immediately.

Key features

  • Full-text search with analysers for many languages, fuzzy matching for typos, phrase and proximity queries, and highlighting.
  • Aggregations for counts, histograms, percentiles and facets, which power filters and dashboards.
  • Query DSL in JSON, plus SQL and ES|QL for analysts who prefer a query language.
  • Vector and hybrid search: dense vectors with approximate nearest-neighbour search, combined with keyword relevance, for semantic search and retrieval-augmented generation.
  • Geo search on points and shapes.
  • Ingest pipelines that parse and enrich documents on the way in.
  • Kibana for exploring data, building dashboards and managing the cluster.

Where Elasticsearch is used

  • Website and e-commerce search: product search with typo tolerance, autocomplete, filters and ranking.
  • Application search: searching documents, tickets, messages or records inside a SaaS product.
  • Log analytics and observability: centralising application and server logs, often next to metrics in Grafana or Prometheus.
  • Security analytics: collecting events for threat detection and investigations.
  • AI retrieval: storing embeddings and text side by side for semantic search and RAG; see RAG and Beyond: The Retrieval Architectures Behind Production AI.

When to choose Elasticsearch, and when not to

Choose Elasticsearch when:

  • Search quality is part of the product: relevance, typo tolerance, synonyms and facets matter to users.
  • You need to search and aggregate large volumes of text or event data quickly.
  • Logs and events from many services must be searchable in one place.
  • You want keyword and vector search in the same engine.

Look elsewhere when:

  • You need a primary database. Elasticsearch has no multi-document transactions, and data is usually copied in from a system of record such as PostgreSQL or MongoDB.
  • Search needs are modest. PostgreSQL's built-in full-text search may be enough, with no extra system to run.
  • The team cannot operate a cluster. Shard sizing, JVM memory, mapping changes that require reindexing and version upgrades take real effort; a managed service reduces it.
  • You only need log collection for a small system. A lighter tool such as Seq can be simpler.

Elasticsearch and its alternatives

OptionWhat it isLicenceBest fit
ElasticsearchLucene-based search and analytics engineAGPLv3, SSPL or Elastic LicenseSearch, observability and security at scale
OpenSearchFork of Elasticsearch 7.10Apache 2.0Teams that want an Apache-licensed engine
Apache SolrLucene-based search serverApache 2.0Established enterprise search setups
Meilisearch, TypesenseLightweight search enginesOpen sourceSimple site and app search
PostgreSQL full-textSearch inside the databasePostgreSQL LicenseModest search without another system

The most common comparison today is Elasticsearch vs OpenSearch. They share a codebase up to 2021, so concepts and much of the API are the same, but they have diverged since: each has added its own features for vector search, observability and query languages. OpenSearch suits teams that require the Apache 2.0 licence or use Amazon OpenSearch Service; Elasticsearch has the larger set of features from its original developer. Apache Kafka often sits in front of either one as the pipeline that carries events into the index.

How we use Elasticsearch at Internative

We use Elasticsearch for advanced search, analytics and observability. Its performance and scalability let us build fast, data-intensive features such as search, filtering and log analysis into modern platforms.

If you are adding search to a product or need to make sense of logs across many services, our web application development and application maintenance and monitoring teams can help you design the right setup.

Frequently asked questions

What is Elasticsearch used for?

Elasticsearch is used for full-text search in websites and applications, for log analytics and observability, for security analytics, and increasingly for vector and hybrid search in AI applications. It is chosen when large volumes of text or event data must be searched and aggregated in milliseconds.

Is Elasticsearch SQL or NoSQL?

Elasticsearch is a NoSQL, document-oriented engine: it stores JSON documents without a fixed relational schema and is queried mainly with its JSON Query DSL over a REST API. It also accepts SQL and ES|QL queries, but it is a search engine, not a relational database, and is usually not used as the primary system of record.

What is the ELK stack?

ELK stands for Elasticsearch, Logstash and Kibana. Logstash collects and transforms data, Elasticsearch indexes and searches it, and Kibana visualises it in dashboards. With the addition of Beats, lightweight data shippers, the set is now called the Elastic Stack; its most common use is log analytics.

Is Elasticsearch free?

The source code is available under the AGPLv3, SSPL or Elastic License, and the default distribution can be used at no cost with its free features. Some advanced features, as well as Elastic's managed cloud service, require a paid subscription. OpenSearch is a fully Apache-licensed alternative.

What are the downsides of Elasticsearch?

It is resource-hungry, especially in memory, and a cluster needs ongoing attention to shard sizing, mappings and upgrades. Changing a field's mapping usually requires reindexing. It is not a transactional database, newly written data appears after a short refresh delay, and licensing has changed over the years, so check the terms for your use.

Related services

Where this topic becomes an engagement.

Keep reading

The articles that follow this one.