{"playbook":"Search","url":"https://agentwranglers.se/playbook/search","updated":"2026-10-27","license":"https://creativecommons.org/licenses/by/4.0/","credit":"Required by the licence: credit Agent Wranglers with a link to the rule or playbook you used.","ids":"Each rule has an id, such as PAY-14, that never changes. Open a rule by its id at /r/PAY-14. Its revision changes whenever its content changes.","how":"Each rule's How and Measured text is on its own page: add .md to its url.","rules":[{"id":"SRH-1","revision":"6f7869da4278","updated":"2026-10-27","name":"Search with the database's own full-text index","level":"Recommended","stack":["postgres"],"rule":"Serve keyword search from a full-text index inside the database. Never search long text with `LIKE '%word%'`, which reads every row.","check":"`EXPLAIN` of every search query shows the full-text index, such as a bitmap index scan on the GIN index in PostgreSQL. A search of the code finds no `LIKE` or `ILIKE` with a leading `%` in search routes.","check_type":"static","url":"https://agentwranglers.se/playbook/search/engines-and-indexes/database-full-text-search","related":["/playbook/stack/databases-and-storage/full-text-search","/playbook/application-security/input-and-injection/cross-site-scripting"],"sources":["https://www.postgresql.org/docs/current/textsearch-tables.html","https://www.postgresql.org/docs/current/textsearch-indexes.html","https://www.sqlite.org/fts5.html"]},{"id":"SRH-2","revision":"5b53a460e3ab","updated":"2026-10-27","name":"Search by meaning and by words","level":"Recommended","rule":"Combine a keyword search and a vector search, and merge the two result lists, for example with reciprocal rank fusion.","check":"The retrieval eval set includes questions with exact product codes. Hybrid search scores at least as well as vector search alone on the whole set.","check_type":"static","url":"https://agentwranglers.se/playbook/search/engines-and-indexes/hybrid-search","related":["/playbook/stack/ai-software/pgvector-first","/playbook/search/relevance/search-quality-tests","/playbook/search/engines-and-indexes/small-semantic-search"],"sources":["https://learn.microsoft.com/en-us/azure/search/hybrid-search-overview"]},{"id":"SRH-3","revision":"e5cb2ed9b97c","updated":"2026-10-27","name":"Search by meaning when the collection is small","level":"Optional","rule":"When a site has 5,000 items or fewer, rank search results by meaning as well as by words.","check":"A set of 10 paraphrased questions, none sharing a title word with its answer, returns the right item in the top three for each.","check_type":"manual","url":"https://agentwranglers.se/playbook/search/engines-and-indexes/small-semantic-search","related":["/playbook/search/engines-and-indexes/hybrid-search","/playbook/search/engines-and-indexes/embedding-model-version","/playbook/search/relevance/search-quality-tests"],"sources":[]},{"id":"SRH-4","revision":"a52222e49568","updated":"2026-10-27","name":"Record the embedding model with every vector","level":"Recommended","rule":"Store the embedding model name and version with every vector. Never compare vectors from two different embedding models.","check":"A query counts vectors per embedding model in the live index. There is exactly one model, and it matches the model in the settings. A filtered search for a small tenant with at least 20 chunks returns 20 rows.","check_type":"static","url":"https://agentwranglers.se/playbook/search/engines-and-indexes/embedding-model-version","related":["/playbook/search/engines-and-indexes/small-semantic-search","/playbook/ai-features/prompts-as-code/pin-model-versions"],"sources":[]},{"id":"SRH-5","revision":"24f34ef6d911","updated":"2026-10-27","name":"Split documents along their structure","level":"Recommended","rule":"Split documents into chunks along headings and paragraphs, of 200 to 800 tokens each. Store each chunk with its document ID, title, heading path and address.","check":"A test chunks the sample documents. Every chunk has 200 to 800 tokens or is a whole short section. Each ends at a sentence end and has a document ID, heading path and address.","check_type":"manual","url":"https://agentwranglers.se/playbook/search/engines-and-indexes/structured-chunks","related":["/playbook/search/relevance/search-quality-tests"],"sources":[]},{"id":"SRH-6","revision":"df3673fc87ba","updated":"2026-10-27","name":"Index only the fields people search","level":"Recommended","rule":"Keep a written list of the fields each search index holds, and leave out every field nobody searches.","check":"A test compares the fields in each index's mapping or schema with the written list and fails on any extra field.","check_type":"manual","url":"https://agentwranglers.se/playbook/search/index-contents-and-sync/search-index-fields","related":["/playbook/data/caches-and-copies/source-of-truth","/playbook/compliance/records-and-data-map/data-map","/playbook/search/index-contents-and-sync/erase-from-indexes"],"sources":["https://eur-lex.europa.eu/eli/reg/2016/679/oj"]},{"id":"SRH-7","revision":"35a73c5c8aff","updated":"2026-10-27","name":"Keep search indexes in step with their source","level":"Recommended","rule":"Update or remove a record's index entries within a set time after the source changes, such as 15 minutes, through a reliable queue. Rebuild the whole index on a schedule to repair drift.","check":"Delete a test record at the source. Within the set time, a search for its unique phrase returns nothing. A nightly job compares record IDs in the source and the index and alerts on any difference.","check_type":"static","url":"https://agentwranglers.se/playbook/search/index-contents-and-sync/search-index-sync","related":["/playbook/data/caches-and-copies/source-of-truth","/playbook/stack/databases-and-storage/full-text-search","/playbook/events/publishing-events/outbox","/playbook/search/index-contents-and-sync/erase-from-indexes"],"sources":["https://learn.microsoft.com/en-us/azure/architecture/databases/guide/transactional-out-box-cosmos"]},{"id":"SRH-8","revision":"a169904289c4","updated":"2026-10-27","name":"Remove erased records from every index","level":"Required","risk":"data","rule":"Delete a record's entries from every keyword and vector index in the same job that deletes or erases the record. Include chunks, suggestions and cached result pages.","check":"Erase a test person who wrote three records. Within the stated delay, search every index for their email, their name and a unique phrase from each record. Each search returns 0 documents, and autocomplete suggests none.","check_type":"static","url":"https://agentwranglers.se/playbook/search/index-contents-and-sync/erase-from-indexes","related":["/playbook/search/index-contents-and-sync/search-index-fields","/playbook/website/privacy/data-requests","/playbook/search/index-contents-and-sync/search-index-sync","/playbook/compliance/records-and-data-map/data-map"],"sources":["https://eur-lex.europa.eu/eli/reg/2016/679/oj"]},{"id":"SRH-9","revision":"8f65e1a770fa","updated":"2026-10-27","name":"Rebuild an index under a new name and switch an alias","level":"Recommended","stack":["postgres"],"rule":"Point the app at an alias, never at an index by name. Build each new version of the index beside the old one, compare them, then move the alias in one step.","check":"During a full rebuild on staging, a script searches every second. No search fails or returns an empty page. The app's settings name the alias, and a code search finds no versioned index name outside the rebuild job.","check_type":"static","url":"https://agentwranglers.se/playbook/search/index-contents-and-sync/reindex-with-alias","related":["/playbook/search/relevance/search-quality-tests"],"sources":["https://docs.opensearch.org/latest/im-plugin/index-alias/"]},{"id":"SRH-10","revision":"8016666ff8ea","updated":"2026-10-27","name":"Filter search results by access inside the query","level":"Required","risk":"data","applies":["accounts"],"stack":["postgres"],"rule":"Put the user's access filter into every keyword and vector search query itself. Hits, totals, facets, suggestions, excerpts and chunks sent to a model then come only from records the user may see.","check":"Create two test accounts, each with a record holding a made-up word only it contains. Signed in as account A, search for account B's word. The answer has 0 hits, a total of 0, no suggestion and no facet count above 0. Give a test user access to a document, search for it, then remove the access. The next search returns nothing from that document, even before the index updates.","check_type":"static","url":"https://agentwranglers.se/playbook/search/access-and-limits/search-access-filter","related":["/playbook/data/multi-tenancy/tenant-scoped-storage","/playbook/data-engineering/access-and-bi-tools/dashboard-row-security","/playbook/data/multi-tenancy/tenant-isolation","/playbook/accounts/roles-and-permissions/object-access"],"sources":["https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html","https://github.com/GenAI-Security-Project/GenAI-LLM-Top10/blob/main/2026/final/LLM09_VectorAndEmbeddingWeaknesses.md"]},{"id":"SRH-11","revision":"b7cf6cedaee0","updated":"2026-10-27","name":"Cap the size of every search","level":"Recommended","rule":"Reject search text over a fixed length, such as 200 characters, and return a fixed number of hits per page. Stop deep paging at a fixed depth, such as 1,000 hits.","check":"Send a search of 201 characters. The answer is 400 and names the limit. Ask for page 51 at 20 hits a page. The answer is 400 or an empty page, within the query time limit.","check_type":"static","url":"https://agentwranglers.se/playbook/search/access-and-limits/search-limits","related":["/playbook/api-design/lists/page-size-limit","/playbook/data/operations/query-timeouts","/playbook/application-security/limits-and-business-logic/rate-limits"],"sources":["https://www.postgresql.org/docs/current/textsearch-controls.html"]},{"id":"SRH-12","revision":"d478e5b99b85","updated":"2026-10-27","name":"Keep personal data out of search logs","level":"Required","risk":"data","rule":"Log searches without user, account or session IDs, and drop queries that look like an email address, a phone number or an ID number. Delete raw search logs after a fixed time, such as 90 days.","check":"Search for `anna@example.com` and `19840512-1234` on staging. The search log holds neither, and no log row has a user or session ID. A query finds no raw log row older than the stated period.","check_type":"static","url":"https://agentwranglers.se/playbook/search/access-and-limits/search-log-privacy","related":["/playbook/search/relevance/search-quality-tests","/playbook/operations/logs/logs-without-personal-data","/playbook/search/relevance/zero-result-searches"],"sources":["https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html","https://eur-lex.europa.eu/eli/reg/2016/679/oj"]},{"id":"SRH-13","revision":"1460fce7b050","updated":"2026-10-27","name":"Set the language of every search field","level":"Recommended","stack":["postgres"],"rule":"Choose the language rules for each searched field on purpose. Test word endings, accents and typos with a fixed list of word pairs.","check":"A test file holds at least 20 word pairs per supported language, such as \"running\" and \"run\", \"Hôtel\" and \"hotel\", or \"recieve\" and \"receive\". Searching each word of a pair returns the same record in the top 10.","check_type":"command","url":"https://agentwranglers.se/playbook/search/language-and-matching/search-language","related":["/playbook/localization/text-handling/locale-collation"],"sources":["https://www.postgresql.org/docs/current/textsearch-tables.html","https://www.postgresql.org/docs/current/unaccent.html","https://www.postgresql.org/docs/current/pgtrgm.html"]},{"id":"SRH-14","revision":"ddb0d843f3ff","updated":"2026-10-27","name":"Split compound words in languages that join them","level":"Recommended","stack":["postgres"],"rule":"For Swedish, German, Dutch, Finnish, Norwegian and Danish fields, split compound words into their parts at index and query time. A search for one part then finds the whole word.","check":"A test holds at least 20 compound pairs per supported language, such as \"vinterjacka\" and \"jacka\", or \"Kinderwagen\" and \"Wagen\". A search for each part returns the record holding the compound in the top 10.","check_type":"static","url":"https://agentwranglers.se/playbook/search/language-and-matching/compound-words","related":["/playbook/localization/text-handling/locale-collation"],"sources":["https://docs.opensearch.org/latest/analyzers/token-filters/dictionary-decompounder/","https://www.postgresql.org/docs/current/textsearch-dictionaries.html"]},{"id":"SRH-15","revision":"2efb21a33363","updated":"2026-10-27","name":"Match how people ask as well as title words","level":"Recommended","rule":"Site search, ask endpoints and agent tools drop filler words and match word forms, so a plain question finds the right page.","check":"A fixed set of at least 20 plain questions returns the expected page first for each. For example, \"how do I know if my site is down\" returns the uptime page.","check_type":"manual","url":"https://agentwranglers.se/playbook/search/language-and-matching/match-plain-questions","related":["/playbook/agents-as-users/ready-for-ai-agents/agent-path-tests","/playbook/documentation/help-centres-and-user-guides/failed-searches","/playbook/search/relevance/search-quality-tests","/playbook/agents-as-users/ready-for-ai-agents/nlweb"],"sources":[]},{"id":"SRH-16","revision":"28d3d2223551","updated":"2026-10-27","name":"Give every item the words people use for it","level":"Optional","rule":"Store a short list of aliases with each page, product or rule, and let search read them.","check":"A test sends each alias as a query on its own. Its item comes first every time.","check_type":"command","url":"https://agentwranglers.se/playbook/search/language-and-matching/item-aliases","related":["/playbook/agents-as-users/ready-for-ai-agents/topic-index","/playbook/search/relevance/zero-result-searches"],"sources":[]},{"id":"SRH-17","revision":"38f044634de2","updated":"2026-10-27","name":"Test search results with a fixed query set","level":"Recommended","rule":"Keep a labelled set of at least 50 searches people make, each with the records it must find. Fail the build when recall at the number of results you show or send to a model falls under a stored target.","check":"CI runs the query set and fails when recall at k falls under the stored target. Lower the weight of the name field so expected records drop out of the top k. The build fails and names the queries.","check_type":"command","url":"https://agentwranglers.se/playbook/search/relevance/search-quality-tests","related":["/playbook/search/engines-and-indexes/hybrid-search","/playbook/search/engines-and-indexes/small-semantic-search","/playbook/search/engines-and-indexes/structured-chunks","/playbook/search/index-contents-and-sync/reindex-with-alias","/playbook/search/access-and-limits/search-log-privacy","/playbook/search/language-and-matching/match-plain-questions","/playbook/ai-features/evals-and-quality/llm-evals","/playbook/search/relevance/zero-result-searches"],"sources":[]},{"id":"SRH-18","revision":"cc42d27270f0","updated":"2026-10-27","name":"Say when nothing fits","level":"Recommended","rule":"Never pad search results with weak matches. When no result passes a set score, say so and link the full index.","check":"Five queries on topics the site does not cover each return an empty result list and the \"nothing fits\" answer, with the index link.","check_type":"manual","url":"https://agentwranglers.se/playbook/search/relevance/say-when-nothing-fits","related":["/playbook/ai-features/retrieval/no-match-answer"],"sources":[]},{"id":"SRH-19","revision":"76217969265b","updated":"2026-10-27","name":"Watch searches that find nothing or get no click","level":"Recommended","rule":"Count each week's share of searches with no hits and with no click on any hit, per query. Review the 20 most frequent of each every month.","check":"The dashboard shows the weekly no-hit and no-click shares for the last 12 weeks, and the two top-20 lists. Each monthly review leaves a dated note with the changes made.","check_type":"manual","url":"https://agentwranglers.se/playbook/search/relevance/zero-result-searches","related":["/playbook/search/access-and-limits/search-log-privacy","/playbook/search/relevance/search-quality-tests","/playbook/search/language-and-matching/item-aliases"],"sources":[]}]}