RousselTMLEARNING

Article · Elasticsearch: from discovery to expertise

Mappings and text analysis

1. Field types #

The right type for the right use.

Types #

TypeForExample
textFull-text search (analyzed)Product description
keywordFilters, sorting, aggregations (exact value)Country code, status, identifier
long, double, scaled_floatCalculations, rangesPrice, duration
dateTime series@timestamp
ip, geo_pointIP addresses (CIDR ranges), locationsclient.ip, location
nestedArrays of objects queried object by objectOrder lines
PUT products
{
  "mappings": {
    "dynamic": "strict",
    "properties": {
      "name":  { "type": "text", "analyzer": "french", "fields": { "raw": { "type": "keyword" } } },
      "sku":   { "type": "keyword" },
      "price": { "type": "scaled_float", "scaling_factor": 100 },
      "lines": { "type": "nested", "properties": { "sku": { "type": "keyword" }, "qty": { "type": "integer" } } }
    }
  }
}
Common mistake: Dynamic mapping guesses types from the first document: a string becomes text + keyword, a number written in quotes stays a string. In production, define mappings in templates and use dynamic: strict or runtime.

2. Text analysis #

What actually gets indexed.

Analyzers #

Analysis chain of a text field
POST _analyze
{ "analyzer": "french", "text": "L'été arrive, les arrivées sont prévues." }

PUT articles
{
  "settings": {
    "analysis": {
      "analyzer": {
        "fr_custom": { "tokenizer": "standard",
                       "filter": [ "lowercase", "asciifolding", "french_elision", "french_stop", "french_stemmer" ] }
      },
      "filter": {
        "french_elision": { "type": "elision", "articles_case": true, "articles": ["l", "d", "j", "qu", "c", "n", "s", "t", "m"] },
        "french_stop":    { "type": "stop", "stopwords": "_french_" },
        "french_stemmer": { "type": "stemmer", "language": "light_french" }
      }
    }
  }
}
Good practice: Always test an analyzer with _analyze on real sentences: it is the fastest way to understand why a search does not find a document.

📄 Elasticsearch mappings and text analysis: field types, analyzers and dynamic mapping →

My progress

  • ⏱ Estimated time : ≈ 5 min

Sign in to track your progress and take notes. Sign in

⭐ Rate this lesson

5.0 initial rating from the teaching team

Sign in to rate this lesson →

💬 Recent discussions about this course

Ask a question about this lesson →See all discussions about this course

Course Glossary

RBAC (Role-Based Access Control)

An access control method where permissions are assigned to specific roles (e.g., admin, reader) rather than directly to individual users.

Authentication

The process of verifying the identity of a user or system (e.g., login/password, tokens, biometrics).

Authorization

The process that occurs after authentication to determine if the entity has the necessary rights and privileges to access a resource.

API Key

A unique alphanumeric code used to identify, authenticate, and authorize access to an Application Programming Interface (API).

Architecture

The overall structural design of an IT system, defining its various components, their relationships, and the principles guiding its evolution.

Repository

A centralized storage location. This can refer to a source code repository (e.g., Git) or an artifact and binary repository (e.g., Harbor, Nexus, Arti...

Elasticsearch

A distributed, RESTful search and analytics engine capable of addressing a growing number of use cases, built on Apache Lucene.

Recommended Articles

Full-text search in OpenSearch: analyzers and relevance

Mastering full-text search: inverted index, analyzers (including French), the _analyze API, match...

Elasticsearch best practices: mappings, shards, lifecycle and operations

Elasticsearch best practices: shard sizing, explicit mappings, templates, ILM, JVM memory, securi...

Elasticsearch ingestion: Bulk API, ingest pipelines, enrich and reindex

Ingest and transform data in Elasticsearch: Bulk API, ingest pipelines and processors (grok, diss...

Index Lifecycle Management (ILM): data tiers, rollover and retention

Automate the index lifecycle with ILM: hot, warm, cold and frozen data tiers, rollover by size an...

Elasticsearch data streams and templates: component templates, index templates and time series

Manage timestamped data with data streams: index templates and component templates, the type-data...

Vector search and RAG with Elasticsearch: dense_vector, kNN, hybrid search and RRF

Build semantic search with Elasticsearch: embeddings, the dense_vector field, kNN search, semanti...

Transforms and enrich: summarising and enriching data in Elasticsearch

Build entity-centric indices with pivot and latest transforms, and enrich documents at ingest tim...

Grafana Loki vs Elasticsearch: the battle of log storage

A comparison between Loki, the Prometheus-inspired log system, and Elasticsearch, the reference f...

Advanced Elasticsearch security: TLS, certificates, API keys, FLS, DLS and audit

Secure Elasticsearch in depth: transport and HTTP TLS, certificate management with elasticsearch-...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!