Elasticsearch : recherche avec filtres
Par pepin le mercredi, novembre 17 2021, 14:28 - Elasticsearch - Lien permanent
curl -XGET 127.0.0.1:9200/movies/_search?pretty -d ' { "query":{ "bool": { "must": {"term": {"title":"trek"}}, "filter": {"range": {"year": {"gte": 2010}}} } } }'
Filter by exact values
{"term": {"year": 2014}}
Match if any exact values in a list match :
{"terms": {"genre": ["Sci-Fi","Adventure"]}}
Find number or dates in a given range (gt,gte,lt,lte)
{range": {"year": {"gte": 2010}}}
Find document where a field exists :
{"exists": {"field": "tags"}}
Find document where a field is missing :
{"missing": {"field": "tags"}}
Combine filters with Boolean logic (must, must_not, should)
Voir aussi :
Match, Match_all, Multi_Match, Bool