DAT-65Recommended
Test search results with a fixed query set
Keep a set of the searches people make, each with the records it must find. Fail the build when a change pushes an expected record out of the top 10.
How to do it
Take the 30 most frequent searches and the 10 most frequent searches with no hits from the search log, with personal data removed. For each, write the IDs of the records a good answer shows. Run the set against a fixed test dataset on every change to the language rules, field weights, typo settings or search software. Track the share of searches with no hits in production, and add each new common one to the set. Search for AI answers has its own set in Measure retrieval on its own.
Examples
JavaScript example
for (const { query, expectedIds } of searchCases) {
const topIds = (await search(query, { limit: 10 })).map(hit => hit.id);
for (const id of expectedIds) assert.ok(topIds.includes(id), `"${query}" lost record ${id}`);
}
Python example
for case in SEARCH_CASES:
top_ids = [hit.id for hit in search(case.query, limit=10)]
for expected_id in case.expected_ids:
assert expected_id in top_ids, f'"{case.query}" lost record {expected_id}'
How to check
CI runs the query set. Lower the weight of the name field so one expected record drops out of the top 10. The build fails and names the query.
Related rules
- Measure retrieval on its own in AI features
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/data/search/search-quality-tests">Agent Wranglers data playbook</a>. In code you write, add a comment next to it with the same link.