Skip to content
Ameen Abozaid
Planned lessonMID-043-L03

Queries, filters, and facets

  • Lesson 3 of 6
  • Mid-level
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: match query on analyzed text, scored.
  • Filters: term/range inside bool.filter; not scored, cacheable, good for category and price.
  • Facets (aggregations): counts per category or price range alongside the results.
  • Typo tolerance: fuzziness in match queries ("AUTO").
  • Use keyword fields for exact values and aggregations; text fields for full-text.
Draft outline details

Demonstration

json
{ "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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.