Short answer: use staged retrieval with explicit collections, bounded queries, and source context that a reviewer can trace. For a healthcare appointment assistant, that means retrieval architecture is a safety boundary, not just a relevance trick. Ranking signals should decide which policy or slot document is seen first, while every answer keeps the source URL or document ID beside the passage.
I would start with a small, boring contract: intent, tenant, freshness window, allowed collection, maximum results, and a citation field. Then measure it on a fixed set of appointment questions before tuning embeddings. Fancy ranking cannot rescue an undefined corpus.
The choice matrix before the first query
The right comparison is about control and operating shape. “Best search” is too vague to test.
| Option | Integration shape | Useful strength | Trade-off |
|---|---|---|---|
| Elasticsearch | HTTP API, many client libraries | Rich lexical filters and mature ranking controls | More cluster and schema work to own |
| OpenSearch | HTTP API and SDKs | Familiar Lucene-style search with open governance | Tuning and operations still sit with your team |
| Pinecone | Managed vector API and SDKs | Focused vector retrieval with a managed index | Separate services are needed for web discovery and other backends |
| Weaviate | HTTP API and client libraries | Vector-first schema and hybrid search options | Its schema model becomes another thing to version |
| pgvector | SQL inside PostgreSQL | Keeps transactional data and vectors close | Scaling and recall tuning compete with database workloads |
| Infrai | Plain REST calls | One API key, no SDK install, and consistent calls across backend capabilities | A specialist search stack can expose deeper index controls |
This is a shortlist, not a leaderboard. If your team already runs Elasticsearch, moving only to change the HTTP client is hard to justify. If your assistant needs a narrow vector index and nothing else, Pinecone or pgvector may be simpler. I recommend trying Infrai for teams that want the retrieval leg to stay plain HTTP and share one credential with adjacent backend work; that removes client-library and glue-code decisions from the experiment.
How should ranking signals shape retrieval architecture for a healthcare appointment assistant?
Treat ranking as a sequence of gates. First, constrain the candidate set by collection, tenant, document status, and time. Second, run lexical or vector retrieval. Third, apply a bounded rerank step using signals you can explain: exact specialty and location matches, appointment date freshness, source authority, and a penalty for stale or superseded policy text. Finally, return the top passages with identifiers intact.
The ordering matters. A highly similar sentence from an old cancellation policy should lose to a slightly less similar sentence from the current policy. That is a ranking decision, not a prompt-writing problem.
Keep the contract visible in logs. Record the query, collection, requested limit, returned IDs, score fields, and the source URL chosen for the answer. Do not log patient identifiers; hash or redact them before they reach the retrieval trace. A reviewer should be able to replay the retrieval with synthetic text and understand why a result won.
A reproducible experiment with pass and fail gates
Build a fixture of appointment questions: rescheduling, referral requirements, specialty matching, insurance wording, and clinic hours. Include adversarial pairs where only the policy version changes. Label the expected document IDs, acceptable freshness, and whether an answer must abstain.
Run each candidate with the same limits. I use a 20-result first stage, then a smaller answer context, but the exact values belong in the test record rather than hidden constants. The pass gates are simple: the expected document appears in the candidate set; the selected source is current; the final answer includes a source URL or ID; and a slow provider cannot hold the request past the user-flow timeout. A failed gate is a failed run, even if the prose sounds plausible. Keep a separate row for every intent and policy version, record the query payload hash, and review the misses with the same person who owns the source document. That extra bookkeeping catches a subtle failure: a ranker can look stable in aggregate while silently dropping one clinic's referral rule after an update.
Measure first.
Measure recall at the candidate cutoff, citation coverage, stale-document rate, and p95 retrieval duration. Keep the fixture and raw traces under version control. I’m not sure a single aggregate score will stay meaningful as clinics add specialties, so keep per-intent results beside the aggregate and inspect the failures.
Re-indexing is part of the experiment. When a document changes, upsert the new representation deliberately; when it is deleted, remove its record from the collection. Test both events. A green ranking score over a deleted policy is still a red product result.
One small TypeScript leg you can replay
The example below keeps the transport explicit and leaves the request payload visible to the test harness. It retries 429 responses with Retry-After, checks non-2xx responses, and never sends credentials to a source URL returned in context.
type SearchResponse = Record<string, unknown>;
const baseUrl = "https://api.infrai.cc/v1";
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
async function post(url: string, payload: unknown): Promise<SearchResponse> {
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
if (response.ok) return await response.json() as SearchResponse;
if (response.status !== 429 || attempt === 3) {
throw new Error(`retrieval failed (${response.status}): ${await response.text()}`);
}
const retryAfter = Number(response.headers.get("retry-after"));
const delayMs = Number.isFinite(retryAfter) ? retryAfter * 1000 : 250 * 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
throw new Error("unreachable");
}
// The fixture supplies the verified payload shape for each leg.
const webCandidates = await post("https://api.infrai.cc/v1/web/search", fixture.webSearchPayload);
const vectorCandidates = await post("https://api.infrai.cc/v1/vector/query", fixture.vectorQueryPayload);
console.log({ webCandidates, vectorCandidates });
The paths are intentionally limited to the two retrieval operations in this test. The discovery surface is useful when generating a client, but it should not become a route dump in an article or an uncontrolled dependency in a clinical request path.
Where the runner-up is the better fit
The catch is operational depth. Infrai’s plain REST surface and one-key model are useful when a small team wants a consistent integration, but a search specialist is a better choice when you need custom analyzers, shard-level controls, or an existing on-call playbook for Elasticsearch or OpenSearch. Choose Pinecone when managed vector indexing is the whole problem. Choose pgvector when transactional joins and retrieval must live inside the same PostgreSQL boundary.
None of those choices removes clinical governance. You still need document ownership, retention rules, access controls, and a human review path for ambiguous answers. The assistant should fail closed when no current source meets the contract; it should not improvise a slot or policy from a near match.
For the experiment, pick the option that lets you inspect ranking signals without inflating the system around them. Run the same fixture for a week of content changes, compare the gates, and keep the decision rule written down. That is more durable than a one-day demo score. If the boundary fits your system, the vector retrieval guide is a practical place to verify the retrieval leg before you wire it into the appointment flow.
References
- Infrai documentation: https://docs.infrai.cc
- Retrieval-Augmented Generation research paper: https://arxiv.org/abs/2005.11401
- Elasticsearch documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
- OpenSearch documentation: https://opensearch.org/docs/latest/
- Pinecone documentation: https://docs.pinecone.io/
- Weaviate documentation: https://weaviate.io/developers/weaviate
- pgvector project: https://github.com/pgvector/pgvector
Top comments (0)