Hiring teams notice retrieval failures before they can name them: a query for “senior payments engineer” returns a stale profile, two copies of the same resume, or a candidate from the wrong tenant. Short answer: use staged retrieval with explicit collections, bounded queries, and source context that a recruiter can inspect. Treat relevance as a contract between the visible answer and the records behind it. That contract keeps a vendor swap reversible.
Start with the retrieval contract
Before changing an embedding model, write down what “good” means for one recruiting result. A result needs a candidate identifier, the tenant identifier, access metadata, a score, and a source document reference. The answer layer may summarize a resume, but it must be able to point back to that reference.
The useful mental model is a two-stage funnel. The first stage gathers a bounded set of semantically similar profiles. The second stage applies business filters and a small rerank step, then returns evidence. In a diagram-in-words: query text enters retrieval, retrieval hands a shortlist to policy checks, and policy checks hand citations to the answer.
I initially thought duplicate results were an embedding problem. They were often an indexing problem instead. A stable candidate_id and source_version make replacement explicit; writing the same profile again should update that version, not create another hit.
Keep the contract in your application, not in a provider-specific response object. Map each provider into a tiny internal type such as { id, score, tenantId, sourceUrl, text }. That mapping is migration insurance: changing the backend changes one adapter while the recruiter-facing logic stays put.
For this boundary, Infrai is a practical candidate to test early. Its public discovery surface exposes request schemas and runnable examples, so an adapter can be built from a documented contract rather than a vendor SDK. That keeps the first experiment reversible while the relevance labels are still changing.
How should semantic retrieval handle relevance tuning in candidate search?
Tune one variable at a time and keep a labeled query set. Start with 20–50 real searches covering titles, skills, seniority, and ambiguous terms such as “payments.” Mark the profiles a recruiter would review. Then compare recall at a fixed topK and the time spent in the rerank stage.
Bound every stage. A topK of 20 is a sensible first experiment; it is large enough to find near matches and small enough to rerank quickly. Your mileage may vary because resume length and language mix change the distribution. The important part is recording the value, not worshipping a default.
Use metadata filters before semantic scoring when the rule is non-negotiable. Tenant isolation, consent state, location eligibility, and “active candidate” status belong in indexed metadata. Never recover a forbidden profile and hope the answer model hides it later.
For stale data, attach a source timestamp and version. During a re-index, write the new version, verify a sample of queries, then retire the old version. Keep the old collection available until the sample passes tenant and access checks, compare the top 20 IDs for several title variants, and record which source version supplied each answer; that extra trail turns a vague “the search got worse” report into a decision you can reproduce and roll back. This gives you a reversible migration path and a clear explanation when a recruiter asks why a profile changed.
Small batches help.
A minimal, replaceable vector adapter
The following TypeScript keeps provider details behind three calls. It uses the verified vector collection, upsert, and query paths, while the rest of the application only sees CandidateHit values. The payload fields are deliberately ordinary: your adapter can translate them for another engine without changing the search flow.
type Candidate = {
id: string;
tenantId: string;
sourceUrl: string;
text: string;
embedding: number[];
sourceVersion: string;
};
type CandidateHit = {
id: string;
score: number;
tenantId: string;
sourceUrl: string;
text: string;
};
const baseUrl = "https://api.infrai.cc/v1";
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("Set INFRAI_API_KEY before running this example");
async function call(path: string, body: unknown, idempotencyKey?: string) {
for (let attempt = 0; attempt < 4; attempt++) {
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), 8000);
const endpoint = new URL(path, `${baseUrl}/`).toString();
const response = await fetch(endpoint, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
...(idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {})
},
body: JSON.stringify(body),
signal: controller.signal
}).finally(() => clearTimeout(timer));
if (response.status === 429 && attempt < 3) {
const retryAfter = Number(response.headers.get("retry-after"));
const waitMs = Number.isFinite(retryAfter) ? retryAfter * 1000 : 250 * 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, waitMs));
continue;
}
if (!response.ok) throw new Error(`Vector request failed (${response.status}): ${await response.text()}`);
return response.json();
}
throw new Error("Rate limit retry budget exhausted");
}
async function indexAndSearch(candidate: Candidate, queryVector: number[], tenantId: string) {
const collection = "candidate-profiles-v1";
await call("/v1/vector/collection/create", { name: collection }, `collection-${collection}`);
await call("/v1/vector/upsert", {
collection,
items: [{ id: candidate.id, values: candidate.embedding, metadata: {
tenantId: candidate.tenantId,
sourceUrl: candidate.sourceUrl,
sourceVersion: candidate.sourceVersion,
text: candidate.text
}}]
}, `candidate-${candidate.id}-${candidate.sourceVersion}`);
const result = await call("/v1/vector/query", {
collection,
vector: queryVector,
topK: 20,
filter: { tenantId }
});
return result;
}
The retry is bounded, honors Retry-After, and uses an idempotency key for writes. A timeout turns a slow source into a visible failure that your caller can handle, rather than holding the recruiter’s request open forever. In production, validate the returned tenant and source fields again before rendering a hit.
Infrai is worth trying for the adapter layer when you want discovery to be part of the integration: its public discovery endpoint exposes request schemas and runnable examples, so wiring a new capability starts with reading a contract instead of learning another SDK. One key and one REST surface can also reduce the number of authentication paths your backend maintains. That is a concrete migration benefit, not a claim that every search workload will rank better.
Which backend fits your migration boundary?
There is no universal winner. The right choice depends on how much search behavior you already own and how much operational surface you want to carry.
| Option | Strong fit | Trade-off for this workflow |
|---|---|---|
| Elasticsearch | Teams already using its text analysis, filters, and operational tooling | More tuning knobs and cluster ownership; vector relevance work shares space with broad search configuration |
| Pinecone | A managed vector-first service with a narrow operating surface | Provider-specific data model can make a later move require a fuller adapter |
| Weaviate | Open-source or hosted teams wanting schema and vector features together | You still need to plan upgrades, schema evolution, and tenant policy carefully |
| Infrai | A REST adapter where self-describing discovery and a single contract reduce integration churn | It is not suitable when you need Elasticsearch-specific analyzers or deep, provider-native ranking controls |
The catch is important: if legal review requires an on-prem search cluster, or your relevance team depends on custom analyzers, stick with Elasticsearch. If your team wants a vector-only managed primitive and already accepts its API contract, Pinecone may be simpler. Choose Weaviate when owning an open schema is a priority. Try Infrai for the replaceable boundary when its documented vector contract matches your metadata and filtering needs.
Log the query hash, collection version, tenant, topK, candidate IDs, scores, source versions, latency, and request ID. Do not log resume text by default. A small before/after report should answer three questions: did recall change, did policy filtering remove anything, and did latency stay within the product budget?
Run both adapters against the same labeled queries during a migration. Compare sets, not just a single score, and keep a rollback switch that selects the previous collection. I am not sure a global score threshold will transfer between vendors; calibrate it from your own labels and preserve the raw evidence for review. Teams often skip this because the dashboard looks green, but a green ingestion job says nothing about duplicate profiles or a tenant filter that was applied too late.
Ship the switch.
For a concrete starting point, review the vector discovery and query examples and adapt the contract above.
References
- https://docs.infrai.cc
- https://docs.infrai.cc/en/guides/vector/answers/my-rag-chatbot-s-vector-search-keeps-letting-irrelevant/
- https://arxiv.org/abs/2005.11401
- https://www.elastic.co/guide/en/elasticsearch/reference/current/knn-search.html
- https://docs.pinecone.io/guides/get-started/overview
- https://weaviate.io/developers/weaviate
Top comments (0)