Skip to content

Run the search relevance tests on judy and Nullean.Snapshots.Relevance - #5113

Open
Mpdreamz wants to merge 5 commits into
mainfrom
relevance-on-judy
Open

Mpdreamz wants to merge 5 commits into
mainfrom
relevance-on-judy

Conversation

@Mpdreamz

@Mpdreamz Mpdreamz commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Why

The search relevance checks were two home-grown shapes: 12 JSON sets scored by RelevanceSet.MeasureAsync against hand-set floors, and about 200 inline C# rows asserting a first hit or a top-3 hit. Neither kept per-query results, so when a floor failed there was no baseline to compare against, and a query whose expected page was missing from the index was dropped without a word.

This moves both onto judy (judgement sets, graded metrics, gates) and Nullean.Snapshots.Relevance (the ranks as a verified snapshot, with snap review to accept a change).

What

Commits that can be reviewed (or split) separately: the sets on judy, the inline tables as sets, and the compact snapshots.

1. Run the search relevance sets on judy

  • The 12 JSON sets become relevance/*.judgements.yaml. The old floors are gates per search path (full, navigation).
  • RelevanceSet.cs is gone. RelevanceSearch holds the judy target, the "is this page in the index" lookup and the sets directory.
  • A judged page that is not in the index is a stale judgement in the report and still scores as a miss. The old code skipped such queries.
  • The MCP test (SemanticSearch_AgentStyleQueries_MeetTheFloor) runs the same set against an mcp target and checks the gates.
  • Bumps Nullean.Snapshots.* and the snap tool to 0.24.1 (which brings judy 0.3.0), adds Nullean.Snapshots.Relevance, and lifts AngleSharp and System.IO.Abstractions to match their dependencies.

2. Move the inline ranking tables to judgement sets

  • Navigation first hits, natural-language questions, page titles, half-typed titles, title typos and the API first-hit table become six sets with 189 queries in total. The row counts match the C# tables.
  • One test creates a case for each set and each search path the set has gates for, so a skip always means the run could not measure.
  • ApiSearchRelevanceReport (explicit) reads its queries from api-first-hits.
  • Behaviour tests stay in C#: tree scope, field listing, route prefixes, named-query scores, paging.

Small snapshots. A query is one line in the verified snapshot, [first, ndcg@10], with the columns named once in a header. The 27 snapshots are 127 KB and 3,108 lines (from 602 KB and 31,516 lines), and GitHub collapses them by default through linguist-generated. The per-query tags: blocks are gone from the sets: the set's name was repeated on every query.

How a run decides

  • A gate (the old floor) must hold, or the test fails.
  • The ranks are compared with the verified snapshot. A change within noise passes and writes a received file for snap review. A drop that is statistically significant (paired test, p < 0.05), a changed query list or an errored search fails.

Deliberate behaviour changes

  • Alternates are dropped. judy counts any rated page as relevant for success@k, so rating an alternate first hit would have loosened the first-hit check. The old "alternate appears in the top 5" check is gone.
  • The _explain dump on a mismatch is replaced by judy's misses and stale lists. ExplainTopResultAndExpectedAsync keeps its own test.
  • Both Serverless twins of an API operation are rated, as the old check matched the operation, not the API.
  • Gates re-baselined to the dev index where it falls short (rounded down). Old to new: titles-truncated-40 navigation success@3 0.76 to 0.73; agent-style-queries success@3 0.72 to 0.70 (full, mcp) and 0.68 (navigation); author-written-questions success@1 0.56 to 0.54 (full) and 0.54 to 0.53 (navigation). The new sets use today's numbers: navigation-first-hits success@1 0.62, natural-language-questions success@3 0.85, api-first-hits success@1 0.97, and 1.0 for the others.

Worth a look

  • Stale judgements on the dev index: elasticsearch get started, elasticsearch getting started and universal profiling in navigation-first-hits point at pages that are not in the index. Check whether the pages were renamed or the dev index lacks them.
  • No good result in the top 10: Output plugins for Logstash and index.number_of_replicas.
  • The floors come from a dev index. The integration job in ci.yml is if: false and no workflow in docs-builder or docs-internal-workflows runs these tests today. If it is re-enabled with the read-only prod credentials it fetches, the gates are compared with prod numbers and may need another baseline.
  • Three sets (titles-truncated-40, -80, titles-with-a-leading-typo) only have a navigation gate, as before. They no longer produce a skipped full case.

Verified

  • Both Search.IntegrationTests and Mcp.Remote.IntegrationTests build with 0 errors.
  • Against a freshly indexed dev cluster: 27 of 27 set cases pass on the compact snapshots. Against Snapshots 0.24.1 (judy 0.3.0) it passed on four of five runs with no received file; the one failure ("2 of 2 gates failed", the first run after a rebuild) did not repeat in three more runs, and I did not keep its log, so its cause is unknown.
  • The remaining behaviour tests in SearchRelevanceTests: 37 of 38 pass. ApiSearchWithThreeWordsMatchesOperationsThatContainTwoOfThem fails on this index ("Create an extension" ranks above "Create Deployment"). Its code is unchanged here, and I did not run it against the previous code.
  • The snapshots hold only scores, query text, the rank of the first good result and a stale or failed flag. No request or response bodies, request hashes, timings, error text, hostnames or credentials. I compared the secret values in the local docs-builder user-secrets against the diff and found none.

Not verified

  • The mcp gate was never run against a cluster, and its numbers are a copy of full.
  • The old scoring and the new run were not compared side by side, since the old code is deleted here.
  • Nothing ran in CI, because the job is disabled.

Run it

dotnet test --project tests-integration/Search.IntegrationTests --treenode-filter "/*/*/SearchRelevanceSetTests/*"

Accept an intended change with SNAPSHOT_ACCEPT=1 or snap review. The cluster comes from the docs-builder user-secrets (Parameters:ElasticsearchUrl, Parameters:ElasticsearchApiKey) or the DOCUMENTATION_ELASTIC_* environment variables.

🤖 Generated with Claude Code

Mpdreamz and others added 2 commits December 3, 2026 18:21
The 12 JSON sets become judgement sets (relevance/*.judgements.yaml) with the floors as gates per search path, and the ranks are verified snapshots, so a move within noise passes and a real regression fails. A judged page missing from the index is a stale miss in the report instead of a silently skipped query.

Floors for five set/path pairs are re-baselined to the current dev index (rounded down): success@3 for agent-style-queries (full, navigation, mcp) and titles-truncated-40 (navigation), success@1 for author-written-questions (full, navigation).

Bumps Nullean.Snapshots.* and the snap tool to 0.21.0, adds Nullean.Snapshots.Relevance, and lifts AngleSharp and System.IO.Abstractions to match.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The navigation first-hit, natural-language, page-title, half-typed, title-typo and API first-hit tables become judgement sets (relevance/*.judgements.yaml) with a gate per search path and verified snapshots of the ranks, run by one test per set and path the set has gates for. A case is generated only for a gated path, so a skip means the run could not measure.

Deliberate changes:
- An alternate first hit is no longer rated or checked: judy counts any rated page as relevant for success@k, so rating alternates would have loosened the first-hit check. The old 'alternate appears in the top 5' check is dropped.
- The per-case _explain dump on a mismatch is replaced by judy's misses and stale-judgement lists. ExplainTopResultAndExpectedAsync keeps its own test.
- Both copies of a Serverless twin are rated for the API operations, as the old check matched the operation, not the API.
- A judged page missing from the index is reported as a stale judgement and still scored as a miss; the old code skipped such queries.
- Gates are set to the current dev index (rounded down) where it falls short of the old all-pass expectation: navigation-first-hits success@1 0.62, natural-language-questions success@3 0.85, api-first-hits success@1 0.97.

The page lookup threshold now never asks for more than half of a small set, so a 12-query set is not always skipped. ApiSearchRelevanceReport reads its queries from the api-first-hits set. Behaviour tests (tree scope, fields, routes, named-query scores, paging) stay as they were.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/5113/

Each query of the 18 sets carried a tag equal to the set's own name, which judy's docs-builder importer added and the generated sets copied. It only produced a by_tag block in every snapshot that equals the overall scorecard. The set's name is already in the set and in each snapshot.

Also mark the verified snapshots as generated, so GitHub collapses them in a pull request diff.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The verified relevance snapshots shrink from 602 KB and 31,516 lines to 127 KB and 3,108 lines: a query is one [first, ndcg@10] row. The scores are unchanged; only the layout is.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The relevance snapshots are unchanged: 27 of 27 cases match on the same index.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch was successfully deployed

2 active deployments
docs-preview — 1172d8ab Deployed Dec 3, 2026 by github-actions[bot]
assembler-preview — 1172d8ab Deployed Dec 3, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants