Récupérer (avancé)
Requêtes
Les requêtes s'écrivent en Query DSL.
Assez différent de SQL et en JSON.
Attention : Requête en POST ?
Oui, car on a un corps dans la requête.
The truth is that RFC 7231—the RFC that deals with HTTP semantics and content—does not define what should happen to a GET request with a body! As a result, some HTTP servers allow it, and some—especially caching proxies—don't.
Méthode : Tout récupérer
Méthode : Par mot exact dans un champ
Méthode : Avec une regex
Conseil : Le scoring
A partir de maintenant, le scoring devient intéressant !
Méthode : Par mot dans tous les champs d'un document
Méthode : Avec plusieurs mots dans un champ
CTRL+C pour copier, CTRL+V pour coller
1
POST /api04/students/_search
2
{
3
"query": {
4
"match": {
5
"about": {
6
"query": "travel cars",
7
"operator": "and"
8
}
9
}
10
}
11
}
POST /api04/students/_search { "query": { "match": { "about": { "query": "travel cars", "operator": "and" } } } }
Par défaut, l'opérateur est or