0Pricing
Elasticsearch & Full Text Search Systems · レッスン

ファセット検索のための集約

Elasticsearchの集約を使い、検索結果とともにファセット、ヒストグラム、概要メトリクスを構築する方法を学びます。

「ファセット検索のための集約」はCoddyKit上の無料Elasticsearch & Full Text Search Systemsレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはElasticsearch & Full Text Search Systems学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Elasticsearch & Full Text Search Systemsコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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.

よくある質問

「ファセット検索のための集約」レッスンは無料ですか?

はい。「ファセット検索のための集約」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Elasticsearch & Full Text Search Systemsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Elasticsearch & Full Text Search Systemsコースには全4レッスンが含まれています。

「ファセット検索のための集約」で何を学びますか?

Elasticsearchの集約を使い、検索結果とともにファセット、ヒストグラム、概要メトリクスを構築する方法を学びます。 ブラウザで直接実行するハンズオンコードでElasticsearch & Full Text Search Systemsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Elasticsearch & Full Text Search Systemsを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのElasticsearch & Full Text Search Systemsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「ファセット検索のための集約」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このElasticsearch & Full Text Search Systemsレッスンでコードを書いて実行できますか?

はい。すべてのElasticsearch & Full Text Search Systemsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. フレーズ検索と近接検索
  2. あいまい検索とワイルドカードクエリ
  3. 検索結果のハイライト
  4. ファセット検索のための集約
← Elasticsearch & Full Text Search Systemsに戻る