1. Field types #
The right type for the right use.
Types #
| Type | For | Example |
|---|---|---|
text | Full-text search (analyzed) | Product description |
keyword | Filters, sorting, aggregations (exact value) | Country code, status, identifier |
long, double, scaled_float | Calculations, ranges | Price, duration |
date | Time series | @timestamp |
ip, geo_point | IP addresses (CIDR ranges), locations | client.ip, location |
nested | Arrays of objects queried object by object | Order 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 becomestext+keyword, a number written in quotes stays a string. In production, define mappings in templates and usedynamic: strictorruntime.
2. Text analysis #
What actually gets indexed.
Analyzers #
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.My progress
Sign in to track your progress and take notes. Sign in
💬 Recent discussions about this course
- Elasticsearch : supprimer automatiquement les logs de plus de 30 jours✓ solved · 1 reply(ies)
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-...