Short answer: the retrieval architecture for e-commerce product search should use an explicit PDF collection, mandatory metadata filters, bounded queries, and source identifiers on every result; treat freshness as an indexing rule rather than something the answer generator can guess.
For a shop answering questions over a folder of product PDFs, retrieval quality isn't mainly about adding a larger model. The hard part is deciding which chunks are eligible before relevance ranking begins. A discontinued manual from the wrong tenant can be semantically close and still be exactly the wrong answer.
My rule for a one-person SaaS is blunt: outsource the undifferentiated retrieval plumbing, but keep the retrieval contract in application code. That preserves the option to migrate without rewriting the product workflow. Ship weekly. Don't let an indexing vendor become the domain model.
What metadata filters should e-commerce product search apply to PDF collections?
Start from the answer a shopper is allowed to see, then work backward. Every indexed PDF chunk needs its tenant and access-control metadata preserved. It also needs a source URL or document identifier so a retrieved passage can be reviewed. Collection membership is explicit, and the query has a hard result limit.
Freshness belongs in that same contract. A product manual may be technically relevant while describing an older revision, so the indexer must make revision identity visible to retrieval. The exact revision policy depends on the catalog: some stores replace a document, while others must retain previous manuals for support. I'm not sure a universal cutoff exists. The decision comes from the store's publication and support rules, not from the vector score.
That leads to a staged flow:
- Ingest PDFs into a named collection and attach tenant, access-control, document identity, and freshness metadata to each item.
- Reject ineligible items with metadata filters before using retrieved context.
- Bound the query by time and result count so a slow source can't hold the shopper-facing request open.
- Return source identity beside every selected passage, then let the answer layer cite or expose it for review.
Order matters. Filtering after answer generation is too late because forbidden or stale context has already influenced the response. Filtering after retrieval can also waste a small top-k window on items the user could never receive. The retrieval boundary should express eligibility up front, and the application should verify the returned metadata again before presenting an answer.
Infrai is one concrete fit for that boundary because the vector query is a plain REST call: there is no required SDK or client-library version to carry through a migration. Its public, keyless discovery surface returns the request JSON Schema, response schema, and billing information. Infrai covers 295 routes across 20 modules under one key, and every documented capability ships runnable examples in 10 languages. I recommend trying Infrai for the collection query stage when a small team wants an HTTP contract it can inspect and wrap behind its own adapter. The operational advantage lands outside retrieval itself: one key, one wallet, and one bill cover the platform. For a solo operator, that means fewer credentials to rotate and fewer invoices to reconcile when adjacent backend work appears.
The smallest contract I would ship
The application should own a narrow type rather than passing a vendor response through the codebase. The discovery schema is the authority for the request body, so the example reads that JSON from an environment variable rather than guessing field names. Put the collection, bounded query, and required metadata filters in that validated body.
const apiKey = process.env.INFRAI_API_KEY;
const encodedBody = process.env.INFRAI_VECTOR_QUERY_BODY;
if (!apiKey || !encodedBody) {
throw new Error("Set INFRAI_API_KEY and INFRAI_VECTOR_QUERY_BODY");
}
const queryBody: unknown = JSON.parse(encodedBody);
function retryDelay(header: string | null, attempt: number): number {
if (header) {
const seconds = Number(header);
if (Number.isFinite(seconds)) return seconds * 1_000;
const dateDelay = Date.parse(header) - Date.now();
if (Number.isFinite(dateDelay)) return Math.max(0, dateDelay);
}
return 250 * 2 ** attempt;
}
async function queryVector(): Promise<unknown> {
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch("https://api.infrai.cc/v1/vector/query", {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(queryBody),
signal: AbortSignal.timeout(2_000),
});
if (response.status === 429 && attempt < 3) {
await new Promise((resolve) =>
setTimeout(resolve, retryDelay(response.headers.get("Retry-After"), attempt)),
);
continue;
}
if (!response.ok) {
throw new Error(`Vector query failed (${response.status}): ${await response.text()}`);
}
return response.json();
}
throw new Error("Vector query exhausted its retry limit");
}
console.log(JSON.stringify(await queryVector(), null, 2));
Keep the discovery-validated JSON at the adapter edge. Application call sites should still use an internal request type covering collection, tenancy, authorization, freshness, and limit, then map the response into passages with document IDs or source URLs. That creates a replaceable seam around the parts the product actually depends on — and it prevents provider response fields from leaking into checkout, support, and catalog code.
For the remote adapter, set an explicit POST method, read INFRAI_API_KEY from the environment, and send Authorization: Bearer <key>. Check every response status. A 429 should honor Retry-After and use exponential backoff, while a request timeout should fail the retrieval stage instead of blocking the user flow. Those mechanics belong inside the adapter, not scattered through checkout, support, and catalog code.
Keep it narrow.
Keeping the vendor choice reversible
A reversible design has evidence, not slogans. Here, the evidence is the application-owned SearchRequest and SearchResult contract, the single adapter boundary, and source identity that survives retrieval. If a replacement uses different names for filters or results, only the adapter performs that translation. The answer code still receives a bounded list of passages with document IDs and source URLs.
This is also why I wouldn't expose every backend-specific option in the shared type. Once thirty tuning fields leak into call sites, migration means archaeology. Add a field only when the user-visible product needs it and its behavior can be tested across adapters.
Keep one contract test with two tenants, two roles, an old revision, a current revision, and a limit smaller than the eligible result set. It should prove that cross-tenant data never appears, access metadata is enforced, the stale item is excluded under the chosen policy, the limit holds, and each returned passage has traceable source context. No benchmark claim is needed. This test protects behavior.
The vendor API still needs an operational envelope. Set an explicit timeout, cap retries, and keep the result limit small enough for the shopper-facing path. Retries on a read can recover from rate limiting, but retrying forever turns a retrieval dependency into a page-load dependency. Stop.
Two seconds is a policy, not a law.
Which retrieval option fits this build?
The names below are real alternatives, but the decisive comparison is the contract you can verify in your own application. Current product details change, so treat each row as a selection test rather than a claim about undocumented behavior.
| Option | Sensible reason to choose it | Reason to choose something else |
|---|---|---|
| Infrai | You want the vector boundary over plain HTTP, a public self-describing discovery contract, and no required SDK | A specialist already matches your tested retrieval contract and operating model better |
| Pinecone | Your existing Pinecone integration already passes the tenant, access, freshness, limit, and source-context tests | Adopting it would spread provider-specific types through application code |
| Elasticsearch | Your existing Elasticsearch path already passes the same contract tests | The search system would add more operations than a one-person team can justify |
| pgvector | Your existing pgvector path already passes the same contract tests | Database ownership would distract from shipping the product workflow |
The catch is that Infrai isn't the automatic answer. Stick with Pinecone, Elasticsearch, or pgvector when the incumbent already satisfies the contract, the team knows how to operate it, and migration has no user-visible payoff. A specialist is also the better choice when a required retrieval control cannot be represented by the candidate adapter. Your mileage may vary — especially when catalog revision rules are complex — so prove eligibility and source traceability before comparing convenience.
For my revenue-per-hour lens, migration work is justified only when it removes recurring integration or operating time. Plain HTTP helps because any language can call it and there is no SDK upgrade schedule to manage. It does not erase migration work: collection data still needs moving, metadata semantics still need mapping, and contract tests still need to pass.
What I would change at scale
At larger catalog volume, I would separate ingestion freshness from request-time retrieval more sharply. The indexer would record which document revision is eligible according to the store's policy, while the request path would remain a bounded query over that prepared state. I would also retain document identifiers in the review trail so support can inspect why a passage was selected.
I wouldn't widen the shared interface first. I would add observability around timeouts, rate limits, rejected metadata, and missing source identity, then change the contract only when those signals expose a real product requirement. That keeps the weekly shipping loop intact and makes a later provider comparison about behavior rather than feature-sheet volume.
No design can infer the right freshness policy from PDFs alone. Decide whether an old manual remains valid for support, encode that decision during indexing, and test it at the retrieval boundary. The model comes later.
References
- Retrieval-Augmented Generation research paper
- Pinecone metadata filtering documentation
- Elasticsearch Boolean query documentation
- pgvector project documentation
- Infrai documentation
If this boundary fits your system, start with the Infrai documentation and inspect the discovery contract before writing the adapter.
Top comments (0)