Recall@K measures how many relevant items appear in the first K slots. NDCG also accounts for rank and graded relevance.
Build the example
Use three documents with grades 3, 2 and 0. In the top two, swapping the first two grades preserves recall when both are considered relevant, while NDCG falls because the stronger result appears later. Compute DCG using gain 2^grade minus 1 divided by log2(rank plus 1), then normalize by ideal DCG.
With ideal grades 3 and 2, ideal DCG at two is 7 plus 3 divided by log base two of 3, about 8.89. The reversed order gives about 7.42, or NDCG about 0.835. Both lists contain the same two relevant documents, so this example isolates ranking quality from coverage.
Watch the failure boundary
Write out a hand-calculated ranked list and compare it to the metric implementation. Keep query-level scores and the aggregate. A jump in the mean can hide a regression on a query class that has fewer examples. Use the same cutoff for both systems and make the relevance grading guide reproducible.
Verify the behavior
Add a query with no judged relevant documents and define how the evaluation handles it before averaging. Record which documents were unjudged. Treating every unjudged result as irrelevant can penalize a system that surfaces new candidates.
Sources
Technical references checked .



