Last active
August 29, 2018 09:08
-
-
Save lucianprecup/4202350 to your computer and use it in GitHub Desktop.
Quelques requêtes Elasticsearch utilisées lors de la démonstration Lucene @LorraineJug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//-- pertinence et idf (Jean-Claude Jean après ville=Rueil) | |
{ | |
"query": { | |
"bool": { | |
"should": [ | |
{ | |
"text": { | |
"nom": "jean" | |
} | |
}, | |
{ | |
"text": { | |
"lieux": "rueil" | |
} | |
} | |
], | |
"must": [], | |
"must_not": [], | |
"minimum_number_should_match": 1 | |
} | |
} | |
} | |
//-- pertinence et idf (Jean-Claude Jean après ville=Rueil) avec explain | |
{ | |
"explain": 1, | |
"query": { | |
"bool": { | |
"should": [ | |
{ | |
"text": { | |
"nom": "jean" | |
} | |
}, | |
{ | |
"text": { | |
"lieux": "rueil" | |
} | |
} | |
], | |
"must": [], | |
"must_not": [], | |
"minimum_number_should_match": 1 | |
} | |
} | |
} | |
//-- retourne des objets de types différents (utiliser les deux types dans requête http) | |
//-- exercice : pour quoi les personnes se retrouvent en premier ? | |
{ | |
"from": 0, | |
"size": 20, | |
"query": { | |
"bool": { | |
"should": [ | |
{ | |
"text": { | |
"nom": "york" | |
} | |
}, | |
{ | |
"text": { | |
"titre": "York" | |
} | |
} | |
], | |
"must": [], | |
"must_not": [], | |
"minimum_number_should_match": 1 | |
} | |
} | |
} | |
//-- highlight et auto-complétion | |
{ | |
"from": 0, | |
"size": 20, | |
"fields": [ | |
"nom.untouched" | |
], | |
"query": { | |
"query_string": { | |
"default_field": "nom.comp", | |
"query": "ce" | |
} | |
}, | |
"highlight": { | |
"number_of_fragments": 0, | |
"fields": { | |
"nom.comp": {} | |
} | |
} | |
} | |
//-- utilisation du champs nom.basic pour faire la différence avec une recherche exacte | |
//-- sans nom.basic | |
{ | |
"from": 0, | |
"size": 20, | |
"query": { | |
"bool": { | |
"should": [ | |
{ | |
"text": { | |
"nom": "céline" | |
} | |
} | |
], | |
"must_not": [], | |
"minimum_number_should_match": 1 | |
} | |
} | |
} | |
//-- avec nom.basic | |
{ | |
"from": 0, | |
"size": 20, | |
"query": { | |
"bool": { | |
"should": [ | |
{ | |
"text": { | |
"nom": "céline" | |
} | |
}, | |
{ | |
"text": { | |
"nom.basic": "céline" | |
} | |
} | |
], | |
"must_not": [], | |
"minimum_number_should_match": 1 | |
} | |
} | |
} | |
//-- fuzzy | |
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"fuzzy": { | |
"nom": { | |
"value": "schvartzeneger", | |
"min_similarity": 0.7 | |
} | |
} | |
} | |
], | |
"must_not": [], | |
"should": [] | |
} | |
} | |
} | |
//-- dimminuer la min_similarity | |
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"fuzzy": { | |
"nom": { | |
"value": "schvartzenegar", | |
"min_similarity": 0.6 | |
} | |
} | |
} | |
], | |
"must_not": [], | |
"should": [] | |
} | |
} | |
} | |
//-- stallone maintenant | |
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"fuzzy": { | |
"nom": { | |
"value": "stalone", | |
"min_similarity": 0.7 | |
} | |
} | |
} | |
], | |
"must_not": [], | |
"should": [] | |
} | |
} | |
} | |
//-- rajouter un prefix_length | |
//-- sans prefix_length | |
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"fuzzy": { | |
"nom": { | |
"value": "celin", | |
"min_similarity": 0.7 | |
} | |
} | |
} | |
], | |
"must_not": [], | |
"should": [] | |
} | |
} | |
} | |
//-- avec prefix_length | |
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"fuzzy": { | |
"nom": { | |
"value": "celin", | |
"min_similarity": 0.7, | |
"prefix_length": 2 | |
} | |
} | |
} | |
], | |
"must_not": [], | |
"should": [] | |
} | |
} | |
} | |
//-- facettes | |
{ | |
"query": { | |
"matchAll": {} | |
}, | |
"facets": { | |
"genre": { | |
"terms": { | |
"field": "genre", | |
"all_terms": true | |
} | |
}, | |
"pays": { | |
"terms": { | |
"field": "pays", | |
"all_terms": true | |
} | |
}, | |
"langue": { | |
"terms": { | |
"field": "langue", | |
"all_terms": true | |
} | |
} | |
} | |
} | |
//-- facettes + filtre | |
{ | |
"query": { | |
"matchAll": {} | |
}, | |
"filter": { | |
"term": { | |
"langue": "français" | |
} | |
}, | |
"facets": { | |
"genre": { | |
"terms": { | |
"field": "genre", | |
"all_terms": true | |
} | |
}, | |
"pays": { | |
"terms": { | |
"field": "pays", | |
"all_terms": true | |
} | |
}, | |
"langue": { | |
"terms": { | |
"field": "langue", | |
"all_terms": true | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment