Queries, filters, and facets
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
write full-text, filtered, and faceted queries.
Planned topics
- Full-text:
matchquery on analyzed text, scored. - Filters:
term/rangeinsidebool.filter; not scored, cacheable, good for category and price. - Facets (aggregations): counts per category or price range alongside the results.
- Typo tolerance:
fuzzinessinmatchqueries ("AUTO"). - Use
keywordfields for exact values and aggregations;textfields for full-text.
Draft outline details
Demonstration
{ "query": { "bool": {
"must": { "match": { "name": { "query": "runing shoes", "fuzziness": "AUTO" } } },
"filter": [ { "term": { "category": "footwear" } }, { "range": { "price": { "lte": 100 } } } ] } },
"aggs": { "by_category": { "terms": { "field": "category" } } } }Check your understanding
Why put category in filter rather than must?
Show answer
Filters are not scored and can be cached.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.