Learnitweb

Index, Document and Field in ElasticSearch

Index

In Elasticsearch, an index is conceptually similar to a table in a relational database, but with important differences in how data is stored and accessed.

An index represents a logical collection of related data. For example, if you are building an application that manages users, products, and orders, you would typically create separate indices such as users, products, and orders. Each index is optimized for fast searching and retrieval of data relevant to that domain.

An index is the fundamental unit of storage in Elasticsearch, meaning that all data operations—such as inserting, updating, searching, or deleting—happen within an index. Understanding this concept is critical because everything else in Elasticsearch is built around how indexes function.

Document

A document is comparable to a row in a relational database table, but it is far more flexible in structure.

Each document represents a single unit of data, such as one user, one product, or one transaction. A document contains multiple fields, and each field holds a piece of information related to that document.

For example, a product document might contain fields such as product name, price, category, and availability status. Unlike traditional relational databases, Elasticsearch allows documents within the same index to have slightly different structures, which makes it highly flexible.

In simple terms, if an index is a container, then a document is an individual item stored inside that container.

Field

A field is equivalent to a column in a relational database, but it plays a much more dynamic role in Elasticsearch.

Each field represents a single attribute of a document, such as a name, number, date, or boolean value. Fields define the structure of a document, and multiple fields together form a complete data record.

What makes fields particularly powerful in Elasticsearch is that they are indexed in a way that allows extremely fast searching, filtering, and aggregation. This is one of the key reasons Elasticsearch is widely used for search-heavy applications.

Understanding the Relationship Between Index, Document, and Field

To summarize the hierarchy in a way that feels intuitive:

  • A field represents a single piece of data and acts like a column in a table.
  • A document is a collection of fields that together represent one complete record.
  • An index is a collection of related documents and acts as the main storage unit in Elasticsearch.

Thinking in this layered structure will help you visualize how data flows through the system.

Index vs Indices vs Indexes

You may encounter different terms when people talk about Elasticsearch, such as index, indices, or indexes. This often causes confusion for beginners.

  • Index is the singular form.
  • Indices is the grammatically correct plural form.
  • Indexes is also commonly used in real-world conversations and documentation.

All three are acceptable and widely understood in the Elasticsearch community. When you see different variations, it does not indicate a difference in meaning—only a difference in linguistic preference.

Using “Index” as a Verb

Sometimes you will hear people say things like:

“Index the documents.”
“Once the data is indexed, searching becomes fast.”

In these cases, index is being used as a verb rather than a noun.

When someone says “index the data,” they mean that Elasticsearch is organizing and storing the documents in a structured way that allows extremely fast retrieval later. This process involves analyzing fields, creating internal data structures, and preparing the data for efficient search operations.

This concept will become much clearer once you start inserting and querying real data, so do not worry if it feels slightly abstract right now.