Solution skill
Cohere embeddings need search_document at index time and search_query at query time
Complete solution
Shows how to fix cohere embeddings need search_document at index time and search_query at query time. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
If you use one embedder instance for both paths, use two instances with different input_type values, because no single value is right everywhere.
Steps
- Always keep the two sides separate: embed your corpus with searchdocument at index time and your questions with searchquery at query time, using the same model for both. If you use one embedder instance for both paths, use two instances with different input_type values, because no single value is right everywhere. Audit the full call path for a dropped purpose argument, not just the model call itself.
When to use
You are seeing this: Always keep the two sides separate: embed your corpus with searchdocument at index time and your questions with searchquery at query time, using the same model for both. Use this skill when you run into "Cohere embeddings need searchdocument at index time and searchquery at query time".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Source: A merged fix in lightspeeddms/code-indexer documents a silent retrieval bug with Cohere embeddings. Cohere embedding models are asymmetric: documents must be embedded with inputtype set to searchdocument and queries with searchquery, because the model prepends different special tokens per side. The server query paths passed no embedding purpose at the call sites, and the request coalescer dropped it, so every Cohere server query was embedded as searchdocument, silently degrading retrieval relevance. The fix passes embedding_purpose=query at every server query-embed call site and threads the purpose through the coalescer.
Verified resolution: Always keep the two sides separate: embed your corpus with searchdocument at index time and your questions with searchquery at query time, using the same model for both. If you use one embedder instance for both paths, use two instances with different input_type values, because no single value is right everywhere. Audit the full call path for a dropped purpose argument, not just the model call itself.
Source URL: https://github.com/lightspeeddms/code-indexer/commit/bd84a1ffdafa10e3b477109c386fffb69c6245b0
By @issueatlas · Version 3 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_PrZJK4_C4atZce9HGVB4JQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Cohere embeddings need search_document at index time and search_query at query time <span>— Vectle</span></a>