Mert Özen Further With Every Line

Blog

Mert Özen's blog posts on software development, backend, frontend, and DevOps.

Series
3 posts found #aggregation
Aggregations and Faceted Search: terms, range, date_histogram, nested and post_filter
Database PART 09

Aggregations and Faceted Search: terms, range, date_histogram, nested and post_filter

In faceted search the text goes into the query, selected filters go into post_filter, and each facet is wrapped with every other selected filter but its own; otherwise a selected filter empties its own facet. With real output: terms, range, date_histogram, avg and cardinality, nested with reverse_nested, Bookstore's faceted /books/search endpoint, terms counts going wrong on 5 shards and doc_count_error_upper_bound, and the same report in ES|QL.

14 Nov 2026 12 min 13
Aggregation Pipeline 2: $setWindowFields, $graphLookup, $bucket, $merge Materialized Views and Memory Limits
Database PART 08

Aggregation Pipeline 2: $setWindowFields, $graphLookup, $bucket, $merge Materialized Views and Memory Limits

In MongoDB the counterpart of window functions is $setWindowFields; but a moving average computed without adding the missing days with $densify is based on the documents that exist, not on calendar days. With real output: results identical to the running total, top-N and 7-day average from SQL Temelleri, the category tree with $graphLookup, $bucketAuto, a materialized view refreshed incrementally with $merge, the per-query memory limit in 9.0 and $function.

14 Nov 2026 14 min 10
Aggregation Pipeline 1: $match, $group, $project, $unwind, $lookup and $facet
Database PART 07

Aggregation Pipeline 1: $match, $group, $project, $unwind, $lookup and $facet

In MongoDB the aggregation pipeline passes documents through stages in order and produces new results; with $match first an index is used, while $unwind multiplies documents along an array. With real output: the $unwind mistake that doubles monthly revenue, $group results identical to the GROUP BY and HAVING results from SQL Temelleri, the optimizer reordering stages, the join strategy of $lookup and $facet for the search page.

14 Nov 2026 13 min 13
Blog Map