Elasticsearch data model mapping¶
Mapping in Elasticsearch defines the schema of an Index, analogous to how a schema defines a table in a relational database management system (RDBMS).^[600-developer-elasticsearch.md] It outlines the structure and characteristics of Fields within a Document.^[600-developer-elasticsearch.md]
Core Concept¶
Elasticsearch organizes data using a hierarchy where an Index is comparable to a database table, a Document is like a row, and a Field is equivalent to a column.^[600-developer-elasticsearch.md] Because documents in Elasticsearch are JSON-like objects, mapping is the process that defines the specific data types and properties for these fields, much like defining column types in MySQL.^[600-developer-elasticsearch.md]
Field Types¶
The mapping configuration dictates how data is stored and queried, primarily through the assignment of data types such as:
text: Used for full-text search. Data is analyzed and tokenized into an Inverted index to support search relevance.^[600-developer-elasticsearch.md]keyword: Used for exact matching (e.g., filtering, sorting). These fields are not analyzed or tokenized.^[600-developer-elasticsearch.md]
Mapping Strategies¶
Mappings can be established using different methods to manage schema evolution:
- Manual Mapping: The user explicitly defines the field types and structure.
- Dynamic Mapping: Elasticsearch attempts to automatically guess and add field types based on the data being indexed.^[600-developer-elasticsearch.md]
Related Concepts¶
- Elasticsearch
- Inverted index
- [[Relational database]]
Sources¶
600-developer-elasticsearch.md