Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
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.
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.
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.
Angular BFF and Aggregation with YARP: Running Proxy Routes Side by Side with Your Own Endpoints
Because YARP routes are normal endpoints, you can serve Angular files, aggregation endpoints and proxy routes from one app on a single origin without CORS; the parts to watch are fallbacks, the timeout budget and second traffic paths. With real output from Bookstore we show a book page endpoint that calls Catalog, Inventory and Ordering in parallel, partial failure, an HttpClient that uses YARP's health data, and an IHttpForwarder that picks a target per institution.
LINQ Aggregation Operators: Count, Sum, Average, Min, Max, Aggregate and MinBy/MaxBy
Why Sum returns 0 and Max throws on an empty sequence, and the nullable selector and DefaultIfEmpty fixes. Count and .NET 6 TryGetNonEnumeratedCount, the return type of Average, the checked overflow of Sum, MinBy/MaxBy returning the element instead of the value, the three overloads of Aggregate, and how many times you enumerate the same query.