0Pricing
Elasticsearch & Full Text Search Systems · Lekcja

Agregacje na potrzeby wyszukiwania fasetowego

Wykorzystają Państwo agregacje Elasticsearch do tworzenia faset, histogramów i zbiorczych miar obok wyników wyszukiwania.

Agregacje na potrzeby wyszukiwania fasetowego to bezpłatna lekcja Elasticsearch & Full Text Search Systems na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Elasticsearch & Full Text Search Systems, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Elasticsearch & Full Text Search Systems zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Beyond Matching

Search finds documents; aggregations summarize them. They power faceted navigation, dashboards, and analytics, all in the same request as the search.

Two Families

Aggregations come in two main families:

  • Bucket aggregations group documents (e.g. by category)
  • Metric aggregations compute numbers (e.g. average price)

A Terms Facet

The terms aggregation produces a bucket per distinct value with counts, the classic facet.

GET /products/_search
{ "size": 0, "aggs": {
  "by_category": { "terms": { "field": "category" } }
}}

size 0 Trick

Setting size: 0 returns no document hits, only the aggregation results, which is efficient when you only want the facets.

Aggregate on keyword

Aggregations run on non-analyzed fields. Use the keyword field, not the analyzed text field, or you will bucket on individual tokens.

{ "terms": { "field": "brand.keyword" } }

Metric Aggregations

Metrics like avg, min, max, and sum compute a single value over matching documents.

"aggs": { "avg_price": { "avg": { "field": "price" } } }

Histograms

A histogram buckets numeric values into fixed intervals, great for price ranges.

"aggs": { "price_ranges": {
  "histogram": { "field": "price", "interval": 100 }
}}

Date Histograms

A date_histogram groups by calendar intervals like day or month, ideal for time-series charts.

"aggs": { "per_day": { "date_histogram": {
  "field": "created", "calendar_interval": "day"
}}}

Nesting Aggregations

You can nest a metric inside a bucket: average price within each category. Nesting is how rich facets are built.

"aggs": { "by_cat": {
  "terms": { "field": "category" },
  "aggs": { "avg_price": { "avg": { "field": "price" } } }
}}

Facets Respect the Query

Aggregations are computed over the documents that match the query and filters, so facet counts naturally reflect the current search context.

Cardinality for Distinct Counts

The cardinality metric gives an approximate distinct-value count, far cheaper than exact counting on large data.

"aggs": { "unique_brands": {
  "cardinality": { "field": "brand.keyword" } } }

Quick Check

Why aggregate on a keyword field instead of a text field?

Recap

You learned aggregations for faceted search: bucket aggregations like terms and histograms, metric aggregations like avg and cardinality, nesting metrics inside buckets, the size: 0 trick, and why facets use keyword fields.

Często zadawane pytania

Czy lekcja „Agregacje na potrzeby wyszukiwania fasetowego” jest bezpłatna?

Tak — pełny tekst „Agregacje na potrzeby wyszukiwania fasetowego” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Elasticsearch & Full Text Search Systems, przejdź na CoddyKit PRO. Kurs Elasticsearch & Full Text Search Systems zawiera 4 lekcji w sumie.

Co nauczysz się w „Agregacje na potrzeby wyszukiwania fasetowego”?

Wykorzystają Państwo agregacje Elasticsearch do tworzenia faset, histogramów i zbiorczych miar obok wyników wyszukiwania. Ćwiczysz Elasticsearch & Full Text Search Systems z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Elasticsearch & Full Text Search Systems?

Nie wymagamy żadnego doświadczenia. Elasticsearch & Full Text Search Systems w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Agregacje na potrzeby wyszukiwania fasetowego”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Elasticsearch & Full Text Search Systems?

Tak. Każda lekcja Elasticsearch & Full Text Search Systems zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Wyszukiwanie fraz i bliskości
  2. Zapytania rozmyte i z symbolami wieloznacznymi
  3. Wyróżnianie wyników wyszukiwania
  4. Agregacje na potrzeby wyszukiwania fasetowego
← Powrót do Elasticsearch & Full Text Search Systems