This article is available in French.
1. La requête bool #
La base de tout.
Score et filtre #
GET products/_search
{
"query": { "bool": {
"must": [ { "match": { "name": { "query": "chaussure trail", "operator": "and" } } } ],
"should": [ { "term": { "brand": { "value": "acme", "boost": 2 } } } ],
"filter": [ { "term": { "in_stock": true } }, { "range": { "price": { "lte": 150 } } } ],
"must_not": [ { "term": { "status": "discontinued" } } ]
} }
}Bonne Pratique : Tout ce qui est oui/non (statut, plage de dates, client) va dans filter : plus rapide, mis en cache, et n'altère pas la pertinence.2. Pertinence #
Comprendre et ajuster le score.
Outils #
- Le score par défaut est BM25 : fréquence du terme dans le document, rareté dans l'index, longueur du champ.
"explain": truedétaille le calcul pour un document.function_scorecombine le score textuel avec la popularité, la fraîcheur (gausssur une date) ou la distance.nestedinterroge chaque objet d'un tableau séparément (sinon « taille 42 » et « couleur rouge » peuvent venir de deux lignes différentes).
3. Agrégations #
Analyser, pas seulement chercher.
Exemples #
GET logs-nginx-*/_search
{
"size": 0,
"query": { "range": { "@timestamp": { "gte": "now-24h" } } },
"aggs": {
"par_heure": {
"date_histogram": { "field": "@timestamp", "fixed_interval": "1h" },
"aggs": {
"erreurs": { "filter": { "range": { "http.response.status_code": { "gte": 500 } } } },
"p95": { "percentiles": { "field": "event.duration", "percents": [ 95 ] } },
"taux": { "bucket_script": { "buckets_path": { "e": "erreurs>_count", "t": "_count" }, "script": "params.e / params.t * 100" } }
}
},
"top_paths": { "terms": { "field": "url.path", "size": 10 } },
"visiteurs": { "cardinality": { "field": "source.ip" } }
}
}À savoir :cardinalityest approximatif (HyperLogLog) ;compositepermet de paginer sur toutes les combinaisons d'une agrégation, contrairement àterms.
ES|QL #
FROM logs-nginx-*
| WHERE @timestamp > NOW() - 24 hours AND http.response.status_code >= 500
| STATS erreurs = COUNT(*) BY url.path
| SORT erreurs DESC
| LIMIT 10My progress
Sign in to track your progress and take notes. Sign in
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
Understanding the concept of score
The concept of score allows Elasticsearch to rank your documents by relevance during a search.
Understanding the Elastic Common Schema (ECS)
As always in our consulting engagements, we recommend that companies harmonise and standardise: k...
License consumption types
Understand the evolution of billing in Dynatrace: the difference between the old licensing model ...
Grafana Alloy: The importance of Self-Monitoring
Discover why and how to configure Grafana Alloy so that it monitors itself, collecting its own lo...
Grafana Alloy: Understanding and exploiting the User Interface (UI)
Discover how to enable, secure, and use Grafana Alloy's built-in web interface to visualize your ...
Grafana Alloy: Introduction and Architecture
Discover the fundamental concepts of Grafana Alloy, the transition from the static Agent to Alloy...
Grafana Alloy: Syntax and Configuration (Alloy Language: River)
As part of a Grafana training or observability training, master the declarative syntax of Grafana...
Grafana Alloy: Metrics Collection (Prometheus & Ecosystem)
Learn how to configure Grafana Alloy to collect, transform, and forward metrics using the Prometh...
Grafana Alloy: Log Management with Loki
Discover how to configure Grafana Alloy to read log files, journald, or network streams, process ...