AI Hints
Home›Elasticsearch Tutorial›Documents, Clusters and Setup
Elasticsearch · Lesson 4 of 120

Documents and Indexes

JSON in, JSON out.

⏱ 2 min read▶ Video at 3:05🎓 Free
Watch this lesson in the Elasticsearch courseWatch on YouTube ↗Full Elasticsearch course

In Elasticsearch, each thing you store is a document, written in JSON. One product, one order, or one log line. Documents of the same kind live together in an index.

  • One thing = one document
  • Written in JSON
  • Grouped in an index

A product document

This is one Trailhead product, as a JSON document. It has fields, like name, brand, price and tags. Tags is a list, and in stock is true or false. Every product will look like this, and they'll all go in an index called products.

product.jsonjson
{
  "name": "Storm Rain Jacket",
  "brand": "Summit",
  "category": "Jackets",
  "price": 129.99,
  "tags": ["hiking", "travel"],
  "in_stock": true
}

A database you know

If you know SQL, here's a rough map. An index is a bit like a table. A document is like a row. And a field is like a column. The big difference is that documents are flexible JSON, built for search.

SQL database

  • TableRowColumn

Elasticsearch

  • IndexDocumentField

Summary

Documents are JSON objects, and an index holds documents of one kind. Next, how Elasticsearch spreads data across machines.

Key takeaways
  • Document = JSON
  • Index = collection
  • Field = key
Next up: Nodes, Shards and Clusters — how it scales