{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreif5hqa5isifaqg6djxgil5dddbgcnzca3bon6uxsxxzlf2t5rr3hq",
"uri": "at://did:plc:lk3jfj3zq4k4wxnk474axylu/app.bsky.feed.post/3mm6wrs62ulj2"
},
"path": "/t/vector-store-search-correct-chunk-only-retrieved-at-top-k-45/1381267#post_1",
"publishedAt": "2026-05-19T07:12:58.000Z",
"site": "https://community.openai.com",
"textContent": "When searching a Vector Store via the `/vector_stores/{id}/search` endpoint, the chunk with the **highest similarity score** is not returned unless `max_num_results` is set to 45 or higher. This violates the basic invariant that `top_k=N` results should be a strict prefix of `top_k=M` results when `M > N`.\n\nThis appears to be a severe HNSW recall issue, not a ranking issue — the correct chunk exists in the index with a high score (0.88), but the retrieval engine fails to surface it at small `top_k` values.\n\n### Environment\n\n * API: `POST /v1/vector_stores/{vector_store_id}/search`\n\n * Vector store: ~40 markdown files, default chunking strategy\n\n * Embedding model: default\n\n * No filters, no custom ranking options, no rewrite_query\n\n * Query: a short non-English search phrase (4 words)\n\n * Expected top result: a specific document (referred to as Doc A below) that is the most semantically relevant to the query\n\n\n\n\n### Reproduction\n\nSame query, same vector store, same API call — only `max_num_results` changes.\n\n#### Run 1: `max_num_results = 50`\n\n\n Rank 1: Doc A score = 0.8838 ← correct, highest score\n Rank 2: Doc B score = 0.8300\n Rank 3: Doc C score = 0.7991\n Rank 4: Doc D score = 0.7846\n ...\n\n\nDoc A ranks #1 with the highest score (0.8838).\n\n#### Run 2: `max_num_results = 2`\n\n\n Rank 1: Doc B score = 0.8300 ← wrong document\n Rank 2: Doc C score = 0.7991\n\n\nDoc A is **completely missing** , despite having the highest score (0.8838) in Run 1.\n\n#### Threshold testing\n\nI tested `max_num_results` at multiple values to find when Doc A first appears in the results:\n\nmax_num_results | Doc A in results? | Doc A rank\n---|---|---\n2 | | -–\n5 | | -–\n10 | | -–\n20 | | -–\n30 | | -–\n44 | | -–\n**45** | | **1**\n50 | | 1\n\nDoc A only appears starting at `max_num_results = 45`, and when it does appear, it is ranked #1 with the highest score by a clear margin.\n\n### Why this is a bug, not expected behavior\n\nIn a correctly functioning vector search:\n\n 1. `top_k = N` results MUST be a strict prefix of `top_k = M` results when `M > N`, assuming deterministic ranking by score\n\n 2. Recall@10 on a small index (~few hundred chunks) should be ≥95% for HNSW with reasonable parameters\n\n 3. A chunk with score 0.8838 should never be excluded from results that include chunks with scores 0.7991 and below\n\n\n\n\nAll three properties are violated here. The most likely root cause is that `ef_search` (HNSW exploration parameter) is set too low and/or scales with `top_k`, causing graph traversal to terminate before reaching the node containing Doc A’s embedding.",
"title": "Vector Store search: correct chunk only retrieved at top_k ≥ 45"
}