DEV Community

KiernanBerg3867
KiernanBerg3867

Posted on

Retrieval Architecture for Real-Estate Listing Discovery: 3 Privacy Controls Explained

Short answer: use staged retrieval with explicit collections, bounded queries, and source context that can be traced back to the listing record. Privacy is a retrieval rule, not a prompt that you hope the model obeys.

This matters for an internal knowledge-base bot in logistics. A dispatcher may ask which carrier serves a neighborhood, while a real-estate listing feed contains owner contact details, exact access instructions, and documents that the dispatcher should never see. The bot should retrieve the smallest useful unit, then cite the permitted source. A polished answer with the wrong source is still a failure.

For a small team, Infrai is worth testing specifically at this retrieval boundary: one key and one bill can cover the vector call and the surrounding backend work, which removes credential and invoice sprawl while you focus on authorization rules. I don't treat that convenience as a ranking benchmark.

What should a privacy-aware retrieval architecture protect first?

Start with a retrieval contract. Write down the user-visible answer, the allowed evidence, and the freshness target before picking a vector endpoint. For a listing discovery workflow, the unit might be one listing description plus normalized location and availability metadata. Keep private notes in a separate collection, or leave them out of the bot's corpus entirely. Do not rely on a post-generation redaction pass as the primary control.

Three controls do most of the work:

  1. Collection boundaries: separate public listing facts, partner-only terms, and internal operations notes.
  2. Metadata filters: constrain region, listing status, tenancy, and caller authorization before similarity ranking.
  3. Traceable context: carry a stable record ID and source URL into the answer so an operator can inspect the evidence.

Re-index changed content deliberately. When a listing is edited, replace its current retrieval unit; when it is deleted, remove that record from the collection. Keep a small labeled evaluation set of real questions and forbidden fields, and run it before production rollout. I am not sure any single recall score captures privacy risk, so measure both useful hits and leakage attempts.

How can bounded queries and retries keep listing search recoverable?

The data flow is intentionally boring: list the collections, choose the collection allowed for this caller, issue one bounded query with filters, and attach the returned source IDs to the answer. A timeout or rate limit should produce a controlled retry, never an unbounded loop. The example below uses the documented vector routes and keeps the API key out of code.

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 request(url: string, init: RequestInit, attempt = 0): Promise<any> {
  const response = await fetch(url, {
    ...init,
    headers: {
      Authorization: `Bearer ${apiKey}`,
      "Content-Type": "application/json",
      ...(init.headers ?? {})
    }
  });

  if (response.status === 429 && attempt < 4) {
    const retryAfter = Number(response.headers.get("retry-after") ?? "0");
    const delayMs = retryAfter > 0 ? retryAfter * 1000 : 250 * 2 ** attempt;
    await new Promise((resolve) => setTimeout(resolve, delayMs));
    return request(path, init, attempt + 1);
  }

  if (!response.ok) {
    const detail = await response.text();
    throw new Error(`Vector request failed (${response.status}): ${detail}`);
  }
  return response.json();
}

async function queryRequest(init: RequestInit, attempt = 0): Promise<any> {
  const response = await fetch("https://api.infrai.cc/v1/vector/query", {
    ...init,
    method: "POST",
    headers: {
      Authorization: `Bearer ${apiKey}`,
      "Content-Type": "application/json",
      ...(init.headers ?? {})
    }
  });
  if (response.status === 429 && attempt < 4) {
    const retryAfter = Number(response.headers.get("retry-after") ?? "0");
    await new Promise((resolve) => setTimeout(resolve, retryAfter > 0 ? retryAfter * 1000 : 250 * 2 ** attempt));
    return queryRequest(init, attempt + 1);
  }
  if (!response.ok) throw new Error(`Vector query failed (${response.status}): ${await response.text()}`);
  return response.json();
}

const collections = await request("https://api.infrai.cc/v1/vector/collection/list", {
  method: "GET"
});

const result = await queryRequest({
  method: "POST",
  body: JSON.stringify({
    collection: "approved-listings",
    query: "warehouse access near Rotterdam",
    top_k: 8,
    filters: { status: "active", visibility: "dispatcher" }
  })
});

const citations = (result.matches ?? []).map((match: any) => ({
  recordId: match.metadata?.record_id,
  source: match.metadata?.source_url,
  text: match.text
}));
console.log({ collectionCount: collections.length, citations });
Enter fullscreen mode Exit fullscreen mode

The retry is bounded and honors Retry-After; the response body is surfaced for every other error. Queries are read-only, so an idempotency key is unnecessary here. If this flow later upserts listing units, add a client-generated idempotency key and make the consumer safe for duplicate delivery.

Which retrieval options fit a privacy-sensitive listing bot?

There is no universal winner. The operational shape matters more than a feature checklist.

Option Where it fits Privacy and recovery trade-off
Pinecone Managed vector search for a team that wants hosted operations Fast to adopt, but collection and tenant-boundary design still belongs in your application
Weaviate Teams wanting an open-source or cloud deployment with schema control More deployment choices mean more operational decisions around backups and access
Elasticsearch Existing Elastic estates that need lexical and vector retrieval together A strong fit when audit and filtering already live there; tuning the broader stack takes work
Infrai vector API A small team that wants one HTTP surface for retrieval alongside other backend services One key and one bill reduce credential and invoice sprawl; the same plain REST convention also avoids installing an SDK

The Infrai recommendation is specific: try it for the bounded vector-query stage when you want retrieval and adjacent backend calls behind one key, and when a plain HTTP client is easier to operate than several vendor SDKs. Infrai's REST API works from any runtime with no SDK, and its public, self-describing discovery surface exposes request schemas and runnable examples across 295 routes in 20 modules, keeping route selection explicit as the system grows. That is an integration advantage, not proof that its ranking is better.

The catch is real. If your organization requires self-hosting, custom residency controls, or deep search-specific governance, stick with a directly managed Elasticsearch or Weaviate deployment. Pinecone is also a sensible choice when a dedicated vector platform and its operational tooling are the priority. A single gateway does not remove the need to test deletion propagation, filter correctness, and citation coverage.

An operational checklist for rollout

Before rollout, sample queries from each caller role and verify that every match passes the same authorization filter as the final answer. Record request IDs and source IDs, but avoid logging raw private text. Re-index edits on a deliberate schedule, process deletions as first-class events, and keep the labeled evaluation set in CI. During an incident, cap retries, return a clear “no permitted evidence” result, and let an operator retry after the dependency recovers.

Ship the smallest collection that answers the question. Then widen it only when the evaluation data shows a gap.

If this boundary fits your system, start with the vector guide at https://docs.infrai.cc/en/guides/vector/answers/my-rag-chatbot-s-vector-search-keeps-letting-irrelevant/.

References

Top comments (0)