Chapter 45 · Amazon Opensearch Service
Subchapter 45.32
references/search-evaluation-guide.mdMarkdown5 KBView on GitHub
Data-driven evaluation that runs real queries against the live index, computes quantitative metrics, and diagnoses issues with actionable recommendations.
Offer evaluation after the search pipeline is configured and working:
“Would you like to evaluate the search quality? I can run test queries, measure relevance metrics, and suggest improvements.”
Ask the user to provide test queries. Assign a capability to each query based on its form:
| Capability | How to detect | Example |
|---|---|---|
exact | Matches a known title/name in the data | The Matrix |
structured | Contains field:value syntax | genres:Drama |
combined | Free text + field:value | space adventure genres:Sci-Fi |
autocomplete | Short prefix (< 5 chars or partial word) | The Ma |
fuzzy | Contains apparent misspelling | Teh Matrx |
semantic | Natural language describing a concept | movies about redemption in prison |
Run all test queries through the search pipeline and collect top-k results for each.
For each query, review the returned documents and assign a relevance grade to each query-document pair. Grade every document in the top-k results — do not skip any.
Grading scale:
| Grade | Label | Criteria |
|---|---|---|
| 3 | Perfect | The document is exactly what a user searching this query would want. For exact queries, the title matches. For semantic queries, the document directly addresses the concept. |
| 2 | Relevant | The document is clearly useful and related to the query intent, but is not the ideal result. |
| 1 | Marginal | The document shares a topic or keyword with the query but does not satisfy the search intent. |
| 0 | Irrelevant | The document has no meaningful connection to the query. |
Judgment prompt — for each query-document pair, evaluate:
Three metrics are computed per query per method, all at cutoff k:
| Metric | Formula | What it measures |
|---|---|---|
| nDCG@k | Normalized Discounted Cumulative Gain | Ranking quality — are the best docs at the top? |
| P@k | Precision at k | What fraction of top-k results are relevant? |
| MRR | Mean Reciprocal Rank | How quickly does the first relevant result appear? |
| Metric | Good (>= ) | Acceptable (>=) | Poor (<) |
|---|---|---|---|
| Mean nDCG@k | 0.70 | 0.50 | 0.30 |
| Mean P@k | 0.60 | 0.40 | 0.20 |
| Mean MRR | 0.70 | 0.50 | 0.20 |
Apply diagnostic rules comparing across methods:
| Tag | What it targets | Example fix |
|---|---|---|
[INDEX_MAPPING] | Field types, analyzers, .keyword sub-fields | Add .keyword to filterable fields |
[EMBEDDING_FIELDS] | Which fields are embedded | Concatenate title + genres before embedding |
[MODEL_SELECTION] | Embedding model quality/type | Switch from sparse to dense, or upgrade model size |
[SEARCH_PIPELINE] | Hybrid weights, normalization | Shift from 0.8/0.2 to 0.5/0.5 balanced |
[QUERY_TUNING] | Field boosts, fuzziness, filter placement | Move filters to bool.filter to avoid score pollution |
The evaluation passes if any of:
Present results, then offer:
If HIGH severity findings exist, recommend option 1 and explain the specific fix.