What Type of Data Does Elasticsearch Use?


Scott Campbell

When working with Elasticsearch, it is important to understand the different types of data that it uses. Elasticsearch is a powerful search and analytics engine that stores, indexes, and searches data in real-time. It is commonly used for applications where fast and accurate search capabilities are required.

Data Types in Elasticsearch

Elasticsearch can handle various types of data, including:

  • Text: Text data type is used for full-text search. It can be analyzed or not analyzed depending on the requirements. Analyzed text fields are broken down into individual terms while indexing, allowing efficient searching.
  • Keyword: The keyword data type is used for exact matches and sorting operations.

    Unlike text fields, keyword fields are not analyzed and are indexed as-is.

  • Numeric: Elasticsearch supports various numeric data types such as long, integer, short, byte, double, float, and half_float. These types are used to store numeric values for mathematical operations like range queries and aggregations.
  • Date: The date data type is used to store dates in Elasticsearch. Dates can be represented in different formats such as strings or long values representing milliseconds since the Unix epoch.
  • Boolean: The boolean data type represents boolean values (true or false).
  • Binary: Binary data type is used to store binary objects like images or files directly within documents.

Elasticsearch also supports complex data structures through the use of nested objects and arrays. These allow you to model more complex relationships between your documents.

Data Mapping in Elasticsearch

Data mapping defines how documents and their fields are stored and indexed in Elasticsearch. It determines the data type of each field and how the data is treated during indexing and searching.

Elasticsearch provides dynamic mapping, which automatically detects field types based on the data provided. However, it is often recommended to define explicit mappings for your fields to ensure consistency and optimize search performance.

Mapping Example:

PUT my_index
  "mappings": {
    "properties": {
      "title": { "type": "text" },
      "date": { "type": "date" },
      "views": { "type": "integer" }

In this example, we define a mapping for three fields: ‘title’, ‘date’, and ‘views’. The ‘title’ field is of type text, ‘date’ field is of type date, and ‘views’ field is of type integer.

By explicitly defining mappings, you have more control over how your data is indexed and searched in Elasticsearch.


Elasticsearch supports various data types such as text, keyword, numeric, date, boolean, and binary. Understanding the different data types and their use cases is crucial when designing an Elasticsearch index. Additionally, mapping allows you to define explicit rules for how your data is handled during indexing and searching.

By leveraging Elasticsearch’s flexibility in handling different types of data and optimizing mappings, you can build powerful search capabilities into your applications.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy